Last active
August 29, 2015 14:15
-
-
Save Tasemu/96d2f431f971c4165815 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 */ | |
(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