Created
October 15, 2014 11:39
-
-
Save anonymous/624ddeb2978ab46fb43a 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
/** @jsx React.DOM */ | |
var isEven = function(n) { | |
return n % 2 === 0; | |
} | |
var Message = React.createClass({ | |
render: function() { | |
return <div>{this.props.name}</div>; | |
} | |
}); | |
var Root = React.createClass({ | |
render: function() { | |
var messages = [1, 2, 3, 4].map(function(x) { | |
// Logic here. | |
if (isEven(x)) { | |
return <Message name={ x } />; | |
} | |
}); | |
// Logic-less here. | |
return <div>{ messages }</div>; | |
} | |
}); | |
React.renderComponent(<Root />, mountNode); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment