Skip to content

Instantly share code, notes, and snippets.

@shashwatbhatt
Created December 10, 2016 06:12
Show Gist options
  • Select an option

  • Save shashwatbhatt/22c1b391cab353bb56541be97a6b8dc4 to your computer and use it in GitHub Desktop.

Select an option

Save shashwatbhatt/22c1b391cab353bb56541be97a6b8dc4 to your computer and use it in GitHub Desktop.
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("content"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment