Skip to content

Instantly share code, notes, and snippets.

@uxnjs01
Last active August 29, 2015 14:27
Show Gist options
  • Save uxnjs01/841070bcc5483832e3e0 to your computer and use it in GitHub Desktop.
Save uxnjs01/841070bcc5483832e3e0 to your computer and use it in GitHub Desktop.
Interactive Component With State
var StateExample = React.createClass({
render: function() {
getInitialState: function() {
return {
likes: 3
}
},
increment: function(e) {
this.setState({ likes: this.state.likes + 1 });
},
return (
<p>
{this.state.likes} people like this.
<button onClick={this.increment}></button>
</p>
);
}
});
@uxnjs01
Copy link
Author

uxnjs01 commented Aug 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment