Skip to content

Instantly share code, notes, and snippets.

@treyhuffine
Last active September 22, 2017 20:37
Show Gist options
  • Save treyhuffine/7df7dc05ee7c2c9d4b6709bc73407470 to your computer and use it in GitHub Desktop.
Save treyhuffine/7df7dc05ee7c2c9d4b6709bc73407470 to your computer and use it in GitHub Desktop.
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