Skip to content

Instantly share code, notes, and snippets.

@prdxs
Created April 21, 2021 07:05
Show Gist options
  • Save prdxs/e014b136dc93ddd7bcded84dc4e7686b to your computer and use it in GitHub Desktop.
Save prdxs/e014b136dc93ddd7bcded84dc4e7686b to your computer and use it in GitHub Desktop.
const PerfClicksButton = memo(({ className, style, children }) => {
const [clicks, setClicks] = useState(0);
const handleClick = useCallback(() => setClicks((clicks) => clicks + 1), []);
return (
<button
className={clsx('ClicksButton', className)}
style={style}
onClick={handleClick}
>
{children} {clicks}
</button>
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment