Skip to content

Instantly share code, notes, and snippets.

@AndreiCalazans
Created February 22, 2018 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreiCalazans/a824e5c04b7cbdaf5f386f8cb562a821 to your computer and use it in GitHub Desktop.
Save AndreiCalazans/a824e5c04b7cbdaf5f386f8cb562a821 to your computer and use it in GitHub Desktop.
class YourCoolComponent extends Component {
constructor(props) {
super(props);
this.state = {
counter: 0,
};
this.add = this.add.bind(this);
}
add() {
this.setState(prevState => ({ counter: prevState.counter + 1 }));
}
render () {
return ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment