Skip to content

Instantly share code, notes, and snippets.

@saurabhpati
Created July 12, 2018 16:43
Show Gist options
  • Save saurabhpati/e1571e08510584fee472fec28e81f61e to your computer and use it in GitHub Desktop.
Save saurabhpati/e1571e08510584fee472fec28e81f61e to your computer and use it in GitHub Desktop.
playing with react
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