Skip to content

Instantly share code, notes, and snippets.

@kouzouigh
Last active June 3, 2018 00:01
Show Gist options
  • Save kouzouigh/03469b1a52d43239c459d9aa9f7dd8e9 to your computer and use it in GitHub Desktop.
Save kouzouigh/03469b1a52d43239c459d9aa9f7dd8e9 to your computer and use it in GitHub Desktop.
Simple React Button Component with increment Event Click Handler
class Button extends React.Component {
state = { counter: 0 };
handleClick = () => {
this.setState(prevState => {
return {
counter: prevState.counter + 1
}
})
};
render() {
return (
<button onClick={this.handleClick}>{this.state.counter}</button>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment