help, i was stuck on this for so long that i’m about to quit coding all together !!
almost done with the project , but the countdown keep going for a sec after telling it to stop , either by start-stop button or reset button which leads to the time to go under 0 on the sec side.
React.useEffect(() => {
if(play){
const interval = setInterval(() => {
clearInterval(interval);
if(sec === 0){
if(min === 0){
setData(prev => (
{...prev,period: prev.period == "Session" ? "Break" : "Session"}));
audioRef.current.play();
setMin(data.period === "Session" ? (data.session) : (data.break));
setSec(59);
setMin(prev => prev -1)
}
else{
setMin(prev => prev -1);
setSec(59);
}
}
else{
setSec(prev => prev -1)
}
},1000)
}
},[sec,play])