Skip to content

Instantly share code, notes, and snippets.

@prdxs
Last active April 1, 2021 15:47
Show Gist options
  • Save prdxs/154930fe71e97377f0dfc3d9e274dc89 to your computer and use it in GitHub Desktop.
Save prdxs/154930fe71e97377f0dfc3d9e274dc89 to your computer and use it in GitHub Desktop.
class ClicksButton extends Component {
constructor(props) {
super(props);
this.state = {
clicks: 0,
};
}
handleClick = () => {
this.setState(({ clicks }) => ({
clicks: clicks + 1,
}));
};
render() {
const { className, style } = this.props;
const { clicks } = this.state;
return (
<button
className={clsx('ClicksButton', className)}
style={style}
onClick={this.handleClick}
>
Clicks {clicks}
</button>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment