Skip to content

Instantly share code, notes, and snippets.

@prdxs
Created April 21, 2021 06:57
Show Gist options
  • Save prdxs/189065e3d396b7f1f433f01c4eb95891 to your computer and use it in GitHub Desktop.
Save prdxs/189065e3d396b7f1f433f01c4eb95891 to your computer and use it in GitHub Desktop.
class PerfClicksButton extends PureComponent {
constructor(props) {
super(props);
this.state = {
clicks: 0,
};
}
handleClick = () => {
this.setState(({ clicks }) => ({
clicks: clicks + 1,
}));
};
render() {
const { className, style, children } = this.props;
const { clicks } = this.state;
return (
<button
className={clsx('ClicksButton', className)}
style={style}
onClick={this.handleClick}
>
{children} {clicks}
</button>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment