1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-21 05:41:17 -04:00

random organization

This commit is contained in:
2022-04-28 19:28:16 -04:00
parent 9e8c3eaa67
commit 383c88d5ef
5 changed files with 39 additions and 33 deletions

View File

@@ -56,17 +56,17 @@ const CopyButton = forwardRef(function CopyButton(
};
useEffect(() => {
// reset to original icon after given ms (defaults to 2 seconds)
if (copied) {
const reset = setTimeout(() => {
setCopied(false);
}, timeout);
return () => clearTimeout(reset);
if (!copied) {
return;
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
return () => {};
// reset to original icon after given ms (defaults to 2 seconds)
const reset = setTimeout(() => {
setCopied(false);
}, timeout);
// cancel timeout to avoid memory leaks if unmounted in the middle of this
return () => clearTimeout(reset);
}, [timeout, copied]);
return (