Hi Tapas! Great article, it's helped me a lot with a countdown feature I'm currently implementing. Wanted to ask, once the timer is expired, is the interval still running? how would you go about stopping its execution as soon as the countdown reached zero? Thanks a lot for your time and effort
Hi Tapas! Great article, it's helped me a lot with a countdown feature I'm currently implementing. Wanted to ask, once the timer is expired, is the interval still running? how would you go about stopping its execution as soon as the countdown reached zero? Thanks a lot for your time and effort
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 itThe 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.
NIce, thanks a lot!