Building Complex Applications With React
Goals
Overview
Steps
Step 1
ListStore = { getItems: function() { return items }, loadItems: function() {}, addItem: function(itemDescription) {}, toggleCompleteness: function(itemId) {} }ListStore.loadItems()Step 2
var Item = React.createClass({ render: function() { var itemClass = this.props.completed ? 'item completed' : 'item' return ( <li className={itemClass}> <span className='complete-button'>{'\u2714'}</span> <div className='description'>{this.props.description}</div> <span className='delete-button'>{'\u2718'}</span> </li> ) }, })<li class='item completed'> <span class='complete-button'>✔</span> <div class='description'>A gallon of milk.</div> <span class='delete-button'>✘</span> </li>Step 3
getInitialState: function() { return ( {items: [ {description: 'a gallon of milk', completed: true, id: 1}, {description: 'a stick of butter', completed: false, id: 2} ]} ) },getInitialState: function() { return ( {items: []} ) },
Explanation
Next Step:
Go on to Loading Items