react template
by spicyj
HTML
<script src="http://fb.me/react-js-fiddle-integration.js"></script>
JavaScript 1.7
/** @jsx React.DOM */
var Node = React.createClass({
getInitialState: function() {
return {childNodes: []};
},
render: function() {
return <ul>
{this.props.children}
{this.state.childNodes.map(function(text) {
return <Node>{text}</Node>;
})}
</ul>;
},
append: React.autoBind(function(newNode) {
this.state.childNodes.push(newNode);
this.forceUpdate();
})
});
var aa = <Node>root</Node>;
React.renderComponent(aa, document.body);
aa.append("child 1");
aa.append("child 2");