Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created June 13, 2016 12:35
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 chuck0523/276d714f3d4e67f92c725a20e180e93f to your computer and use it in GitHub Desktop.
Save chuck0523/276d714f3d4e67f92c725a20e180e93f to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
class Counter extends Component {
constructor() {
super()
this.state = {
count: 0
}
}
render() {
return (
<div>
<p>Count: {this.state.count} </p>
<button onClick={e => this.increment()}>Increment</button>
</div>
)
}
increment() {
this.setState({
count: this.state.count + 1
})
}
}
export default Counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment