Last active
September 22, 2017 20:37
-
-
Save treyhuffine/7df7dc05ee7c2c9d4b6709bc73407470 to your computer and use it in GitHub Desktop.
This file contains 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
class CounterButton extends React.PureComponent { | |
constructor(props) { | |
super(props); | |
this.state = {count: 1}; | |
this.handleClick = this.handleClick.bind(this); | |
} | |
handleClick() { | |
this.setState(state => ({count: state.count + 1})); | |
} | |
render() { | |
return ( | |
<button | |
color={this.props.color} | |
onClick={this.handleClick}> | |
Count: {this.state.count} | |
</button> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment