Skip to content

Instantly share code, notes, and snippets.

@ernestofreyreg
Created June 29, 2017 14:26
Show Gist options
  • Save ernestofreyreg/1a7311a17bef0cb8d383fcc5d8afe728 to your computer and use it in GitHub Desktop.
Save ernestofreyreg/1a7311a17bef0cb8d383fcc5d8afe728 to your computer and use it in GitHub Desktop.
const increaseFn = state => ({count: state.count + 1})
class Counter extends React.Component {
state = {
count: 0
}
increase = () => {
this.setState(increaseFn)
}
render () {
return <button onClick={this.increase}>{count}</button>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment