DEV Community

loading...

Discussion on: Creating a Countdown using React Hooks

Collapse
gsto profile image
Glenn Stovall

Awesome tutorial! One note, you probably want to clear out the interval you created with useEffect as well, otherwise, it'll keep running after your component unmounts.

useEffect(() => {
  const tick = setInterval(() => setNewTime(), 1000); 
  return () => clearInterval(tick) 
}, []);
Enter fullscreen mode Exit fullscreen mode