Hi! I recently started learning Hooks in React and wanted to change my old React Project from FCC with Hooks. I’m changing my Pomodoro (25 + 5 ) Clock, however, it doesn’t work as I expected . If you have any advice for my code It would be really great to have ones. My clock working when I paused with start/pause button but when I clicked only once to start it, it goes under minus. … So it doesn’t change from session mode to break mode. I set setInterval with 100mms now to test it for now.
You can leave me any advice even some articles I can read about Hooks !
It’d be nice if you could share your code on codepen or codesandbox, we could then not only read but also play around with your code to see what’s going on
I think the issue is with the way you handle intervals.
Interval is a side effect an all the side effects in functional components should be handled inside useEffect hook.
Mutations, subscriptions, timers, logging, and other side effects are not allowed inside the main body of a function component (referred to as React’s render phase ). Doing so will lead to confusing bugs and inconsistencies in the UI.