let ProductCategoryRow = React.createClass({ name: "ProductCategoryRow", componentDidMount: function () { console.log("Component did mountDM", this.name); }, getInitialState: function () { console.log("Get Initial State", this.name); return { data: [] }; }, render: function () { return ({this.props.category}); } }); let ProductRow = React.createClass({ name: "ProductRow", componentDidMount: function () { console.log("Component did mountDM", this.name); }, getInitialState: function () { console.log("Get Initial State", this.name); return { data: [] }; }, render: function () { let name = this.props.product.stocked ? this.props.product.name : {this.props.product.name}; return ( {name} {this.props.product.price} ); } }); let ProductTable = React.createClass({ name: "ProductTable", componentDidMount: function () { console.log("Component did mountDM", this.name); }, getInitialState: function () { console.log("Get Initial State", this.name); return { data: [] }; }, render: function () { let rows = []; let lastCategory = null; this.props.products.forEach(function (product) { if (product.category !== lastCategory) { rows.push(); } rows.push(); lastCategory = product.category; }); return ( {rows}
Name Price
); } }); ReactDOM.render( , document.getElementById("content") );