<p><div>
by spicyj
HTML
<script src="http://fb.me/react-js-fiddle-integration.js"></script>
JavaScript 1.7
/** @jsx React.DOM */
var Monkey = React.createClass({
render: function() {
return <div>monkey</div>;
}
});
var Hello = React.createClass({
getInitialState: function() {
return {showMonkey: false};
},
handleClick: React.autoBind(function() {
this.setState({showMonkey: true});
}),
render: function() {
var button = <input type="button" onClick={this.handleClick} value="click me!" />;
var monkey;
if (this.state.showMonkey) {
return <div>
{button}
<Monkey />
<p><div>hello</div></p>
</div>;
} else {
return <div>
{button}
<p><div>hello</div></p>
</div>;
}
}
});
React.renderComponent(<Hello />, document.body);