Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var App = React.createClass({
getInitialState: function(){
return {
active: true
}
},
handleClick: function(){
this.setState({
active: !this.state.active
});
},
render: function(){
var buttonSwitch = this.state.active ? "On" : "Off";
return (
<div>
<p>Click the button!</p>
<input type="submit" onClick={this.handleClick} />
<p>{buttonSwitch}</p>
</div>
);
}
});
React.render(<App />, document.getElementById("app"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment