let intervalID; useEffect(() => { if (isRunning) { intervalID = setInterval(() => { dispatch({ type: "tic-toc" }); }, 1000); } return () => clearInterval(intervalID); }, [isRunning]);