Skip to content

Instantly share code, notes, and snippets.

Created October 15, 2014 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/624ddeb2978ab46fb43a to your computer and use it in GitHub Desktop.
Save anonymous/624ddeb2978ab46fb43a to your computer and use it in GitHub Desktop.
/** @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