<! DOCTYPE html>varToDoList =React.createclass ({render:function() { varCreateItem =function(item) {return<li key={item.id}>{item.text}</li>; }; return<ul>{ This. Props.items.map (CreateItem)}</ul>; }, }); varTodoapp =React.createclass ({getinitialstate:function() { return{items: [], Text: '}; }, OnChange:function(e) { This. SetState ({text:e.target.value}); }, Handlesubmit:function(e) {e.preventdefault (); varNextitems = This. State.items.concat ([{text: This. State.text, Id:Date.now ()}]); varNexttext = ' '; This. SetState ({items:nextitems, text:nexttext}); }, Render:function() { return ( <div> This. state.items}/> <form onsubmit={ This.handlesubmit}> <input onchange={ This. OnChange} value={ This. state.text}/> <button>{' Add # ' + ( This. state.items.length + 1)}</button> </form> </div> ); }, }); Reactdom.render (<todoapp/>, document.getElementById (' example ')); </script> </body>React-conponent-todo