Skip to content

Instantly share code, notes, and snippets.

@Javlopez
Created June 12, 2017 21:28
Show Gist options
  • Save Javlopez/8da33c16eb93f82bf261b8df72c83ab3 to your computer and use it in GitHub Desktop.
Save Javlopez/8da33c16eb93f82bf261b8df72c83ab3 to your computer and use it in GitHub Desktop.
class Button extends React.Component{
state = { counter: 0 };
handleClick = () => {
this.setState((prevState) => ({
counter: prevState.counter + 1
}));
};
render(){
return (
<button onClick={this.handleClick}>
{this.state.counter}
</button>
);
}
}
ReactDOM.render(<Button />, mountNode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment