var Hello = React.createClass({
mixins: [React.addons.PureRenderMixin],
renderCount: 0,
getInitialState: function() {
return {data: {count: {value: 0}}};
},
countUp: function() {
this.state.data.count.value++;
var updata = this.state.data;
this.setState(updata);
},
fourceUpdate: function() {
this.forceUpdate();
},
render: function() {
this.renderCount += 1;
return (
<div>
<div>Count: {this.state.data.count.value}</div>
<div>Render: {this.renderCount}</div>
<button onClick={this.countUp}>Count Up</button>
<button onClick={this.fourceUpdate}>Forde Update</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>