Created
December 25, 2018 12:40
-
-
Save nirsky/3380173fee773d618529ba4906e87d6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Timer = (props) => { | |
| const intervalRef = useRef(); | |
| useEffect(() => { | |
| const id = setInterval(() => { | |
| // ... | |
| }); | |
| intervalRef.current = id; | |
| return () => { | |
| clearInterval(intervalRef.current); | |
| }; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment