Last active
September 30, 2015 15:22
-
-
Save insin/8903094 to your computer and use it in GitHub Desktop.
Block-based template inheritance in React? What would the API look like?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
var Block = React.createClass({ | |
render: function() { | |
} | |
}) | |
var Base = React.createClass({ | |
render: function() { | |
return <html> | |
<head> | |
<meta charset="UTF-8"/> | |
<title>Blocks?</title> | |
</head> | |
<body> | |
<h1>Test</h1> | |
<div id="content"> | |
<Block ref="content"/> | |
</div> | |
</body> | |
</html> | |
} | |
}) | |
var TwoCols = React.createClass({ | |
render: function() { | |
return <Base> | |
<Block ref="content"> | |
<div className="left"> | |
<Block ref="left"/> | |
</div> | |
<div className="right"> | |
<Block ref="right"/> | |
</div> | |
</Block> | |
</Base> | |
} | |
}) | |
var Page = React.createClass({ | |
render: function() { | |
return <TwoCols> | |
<Block ref="left"> | |
<p>Hello left world!</p> | |
</Block> | |
<Block ref="right"> | |
<p>Hello right world!</p> | |
</Block> | |
</TwoCols> | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment