Skip to content

Instantly share code, notes, and snippets.

@Tasemu
Last active August 29, 2015 14:15
Show Gist options
  • Save Tasemu/96d2f431f971c4165815 to your computer and use it in GitHub Desktop.
Save Tasemu/96d2f431f971c4165815 to your computer and use it in GitHub Desktop.
/** @jsx React.DOM */
(function (React) {
var data = [
'Go to work',
'Play Albion Online',
'Keep learning React'
]
var App = React.createClass({
getInitialState: function () {
return {data: []}
},
componentWillMount: function () {
this.state.data = data;
},
render: function () {
return (
<ToDoList tasks={this.state.data} />
)
}
});
var ToDoList = React.createClass({
render: function () {
var tasks = this.props.tasks.map(function (task) {
return <ToDo key={task} task={task} />
});
return (
<ul>
{tasks}
</ul>
)
}
});
var ToDo = React.createClass({
render: function () {
return (
<li>{this.props.task}</li>
)
}
});
React.render(<App />, document.getElementById('example'));
})(React);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment