Skip to content

Instantly share code, notes, and snippets.

@chuck0523

chuck0523/Counter.js

Created Jun 13, 2016
Embed
What would you like to do?
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