Created
December 10, 2016 06:12
-
-
Save shashwatbhatt/22c1b391cab353bb56541be97a6b8dc4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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