Created
November 17, 2017 04:20
-
-
Save dceddia/e43eb4d4192cc59447d3783a00040b31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
class Counter extends React.Component { | |
state = { count: 0 } | |
increment = () => { | |
this.setState({ | |
count: this.state.count + 1 | |
}); | |
} | |
decrement = () => { | |
this.setState({ | |
count: this.state.count - 1 | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
<h2>Counter</h2> | |
<div> | |
<button onClick={this.decrement}>-</button> | |
<span>{this.state.count}</span> | |
<button onClick={this.increment}>+</button> | |
</div> | |
</div> | |
) | |
} | |
} | |
export default Counter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment