var Hello = React.createClass({
renderCount: 0,
getInitialState: function() {
return {value: 0};
},
countUp: function() {
this.setState({value : this.state.value + 1});
},
render: function() {
// count how many times 'render' was called
this.renderCount += 1;
return (
<div>
<div>Count: {this.state.value}</div>
<div>Render: {this.renderCount}</div>
<button onClick={this.countUp}>Count Up</button>
</div>
);
}
});
React.render(<Hello />, document.body);
External resources loaded into this fiddle:
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>