Created
August 26, 2021 14:43
-
-
Save itsMapleLeaf/e3f14a938a4ed79c49525fd1e3f9ba34 to your computer and use it in GitHub Desktop.
how to settimeout with hooks
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
useEffect(() => { | |
const timeout = setTimeout(() => { | |
doSomething() | |
}, 5000) | |
return () => clearTimeout(timeout) | |
}, []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment