Skip to content

Commit

Permalink
Cancel state update on unmount - devfolioco#58 (devfolioco#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
shra1dhar authored Oct 14, 2020
1 parent 6ab32a2 commit be64603
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ const CopyMailTo = ({
};

React.useEffect(() => {
let intervalId: number;
if (showCopied) {
window.setTimeout(() => {
intervalId = window.setTimeout(() => {
setShowCopied(false);
}, 1000);
}
return (() => window.clearInterval(intervalId));
}, [showCopied]);

const allContainerStyles = {
Expand Down

0 comments on commit be64603

Please sign in to comment.