Last active
August 29, 2015 14:27
-
-
Save uxnjs01/841070bcc5483832e3e0 to your computer and use it in GitHub Desktop.
Interactive Component With State
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the tutorial at: http://www.uxnjs.com/how-to-update-state-in-react/