Merge pull request #955 from LikiosSedo/fix/clear-timeout-code-block

fix: add missing `clearTimeout` cleanup in CopyButton useEffect
This commit is contained in:
Rohan Verma 2026-03-24 20:35:35 -07:00 committed by GitHub
commit 7014adb95b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -143,9 +143,11 @@ function CopyButton({
const [hasCopied, setHasCopied] = React.useState(false); const [hasCopied, setHasCopied] = React.useState(false);
React.useEffect(() => { React.useEffect(() => {
setTimeout(() => { if (!hasCopied) return;
const timer = setTimeout(() => {
setHasCopied(false); setHasCopied(false);
}, 2000); }, 2000);
return () => clearTimeout(timer);
}, [hasCopied]); }, [hasCopied]);
return ( return (