Skip to content

Commit be64603

Browse files
authored
Cancel state update on unmount - #58 (#59)
1 parent 6ab32a2 commit be64603

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ const CopyMailTo = ({
8888
};
8989

9090
React.useEffect(() => {
91+
let intervalId: number;
9192
if (showCopied) {
92-
window.setTimeout(() => {
93+
intervalId = window.setTimeout(() => {
9394
setShowCopied(false);
9495
}, 1000);
9596
}
97+
return (() => window.clearInterval(intervalId));
9698
}, [showCopied]);
9799

98100
const allContainerStyles = {

0 commit comments

Comments
 (0)