var TODO_COMPONENT = `
var TodoList = React.createClass({
render: function() {
var createItem = function(itemText, index) {
return
{itemText};
};
return {this.props.items.map(createItem)}
;
}
});
var TodoApp = React.createClass({
getInitialState: function() {
return {items: [], text: ''};
},
onChange: function(e) {
this.setState({text: e.target.value});
},
handleSubmit: function(e) {
e.preventDefault();
var nextItems = this.state.items.concat([this.state.text]);
var nextText = '';
this.setState({items: nextItems, text: nextText});
},
render: function() {
return (
TODO
);
}
});
React.render(, mountNode);
`;
React.render(
,
document.getElementById('todoExample')
);