Created
July 12, 2018 16:43
-
-
Save saurabhpati/e1571e08510584fee472fec28e81f61e to your computer and use it in GitHub Desktop.
playing with react
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
class Button extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { counter : 0 }; | |
} | |
render() { | |
return ( | |
<button onClick={this.handleClick}>{this.state.counter}</button> | |
); | |
} | |
handleClick = () => { | |
this.setState(prevState => ({counter: ++prevState.counter})); | |
} | |
} | |
ReactDOM.render(<Button />, mountNode); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment