Skip to content

Instantly share code, notes, and snippets.

@melvincarvalho
Created August 9, 2019 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melvincarvalho/bfb3b67d6301864fdfd00dbb25bb2290 to your computer and use it in GitHub Desktop.
Save melvincarvalho/bfb3b67d6301864fdfd00dbb25bb2290 to your computer and use it in GitHub Desktop.
update react hook
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