zanetakochanikova / xmas-countdown

0 stars 0 forks source link

useEffect + setInterval #4

Open pkasarda opened 3 years ago

pkasarda commented 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 :-)

zanetakochanikova commented 3 years ago

Good to know. Didn't realize the difference, thanks :-)