Open pkasarda opened 3 years ago
https://github.com/zanetakochanikova/xmas-countdown/blob/cc25da61201aadeb2c0c6949535cb2f4721c98be/src/App.js#L20-L28
calculate is calling setState so it can be just setTimeout instead of setInterval as you don't used dependency array useEffect will run on every render so it will clear interval :-)
calculate
setState
setTimeout
setInterval
useEffect
interval
Good to know. Didn't realize the difference, thanks :-)
https://github.com/zanetakochanikova/xmas-countdown/blob/cc25da61201aadeb2c0c6949535cb2f4721c98be/src/App.js#L20-L28
calculate
is callingsetState
so it can be justsetTimeout
instead ofsetInterval
as you don't used dependency arrayuseEffect
will run on every render so it will clearinterval
:-)