DEV Community

Discussion on: How to create a countdown timer using React Hooks

Collapse
 
atapas profile image
Tapas Adhikary

Hi Pablo,

yes the timer keeps runnig if we are not clearing it. As you see we are using the cleanup function in the useEffect hook to take care of it

return () => clearInterval(interval);
Enter fullscreen mode Exit fullscreen mode

The moment you call the clearInterval(interval); with the respective intervalID you can control the timer. So you can call it based on your use cases.

Thanks for giving it a read and commenting.

Collapse
 
pablowbk profile image
Pablo

NIce, thanks a lot!