Skip to content

Instantly share code, notes, and snippets.

@tylertreat
Created December 31, 2014 20:58
Show Gist options
  • Save tylertreat/b6f73b1d447573783781 to your computer and use it in GitHub Desktop.
Save tylertreat/b6f73b1d447573783781 to your computer and use it in GitHub Desktop.
var Button = React.createClass({
getInitialState: function() {
return {count: 0};
},
render: function() {
return (
<button type="button" onClick={this.handleClick}>
{'Clicked ' + this.state.count + ' time(s)'}
</button>
);
},
handleClick: function() {
// This will trigger a re-render.
this.setState({count: this.state.count + 1});
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment