Skip to content

Instantly share code, notes, and snippets.

@Anirudhk94
Created January 11, 2019 01:23
Show Gist options
  • Save Anirudhk94/c3fd5d939f2f03e345bfabab50348010 to your computer and use it in GitHub Desktop.
Save Anirudhk94/c3fd5d939f2f03e345bfabab50348010 to your computer and use it in GitHub Desktop.
[React] Increment Button Label On Click
class Button extends React.Component {
state = {counter : 0};
changeLabel = () => {
this.setState({
counter: this.state.counter + 1
})
}
render() {
return(
<button onClick={this.changeLabel}>
{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