Last active
August 29, 2015 14:08
-
-
Save OlavHN/982bce14f7ecbceba967 to your computer and use it in GitHub Desktop.
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
var Summary1 = React.createClass({ | |
render: function(() { | |
var cards = this.props.cards | |
return ( | |
<div> | |
<Notification /> | |
<div> | |
cards.map(function(card, i) { | |
return <Card key={'key' + i} data={card}> | |
}) | |
</div> | |
</div> | |
) | |
}) | |
}) | |
var Summary2 = react.createClass({ | |
render: function() { | |
return ( | |
<div> | |
<Notification /> | |
<div> | |
{this.props.children} | |
</div> | |
</div> | |
) | |
} | |
}) | |
React.renderComponent(<Summary1 cards=[1,2,3,4] />, document.body) | |
// or .. | |
React.renderComponent( | |
<Summary2> | |
<Card data={1} /> | |
<Card data={2} /> | |
<Card data={3} /> | |
<Card data={4} /> | |
</Summary2>, document.body) | |
// never renderComponent into a DOM element alreadt owned by a another react app. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment