Skip to content

Instantly share code, notes, and snippets.

@samcorcos
Last active August 10, 2016 10:49
Show Gist options
  • Save samcorcos/cd7fd42baea577a60a35464c802a8937 to your computer and use it in GitHub Desktop.
Save samcorcos/cd7fd42baea577a60a35464c802a8937 to your computer and use it in GitHub Desktop.
import React from 'react'
class App extends React.Component {
constructor(props) {
super(props)
this.state = {
counter: 0
}
this.addOne = this.addOne.bind(this)
}
addOne() {
this.setState({
counter: this.state.counter + 1
})
}
render() {
return (
<div>
<button
onClick={ this.addOne }>
Increment
</button>
{ this.state.counter }
</div>
)
}
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment