Created
August 9, 2019 12:35
-
-
Save melvincarvalho/bfb3b67d6301864fdfd00dbb25bb2290 to your computer and use it in GitHub Desktop.
update react hook
This file contains 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 [seconds, setSeconds] = React.useState(0) | |
React.useEffect(() => { | |
const interval = setInterval(() => { | |
setSeconds(seconds => seconds + 1) | |
}, 3000) | |
return () => clearInterval(interval) | |
}, []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment