const handleStart = () => { setTime(Date.now()); setNow(Date.now()); clearInterval(intervalRef.current); // Edge case: clearing the previous Intervals, intervalRef.current = setInterval(() => { setTime(Date.now()); }, 10); return () => clearInterval(intervalRef.current); }; Like whenever we click restart button more than one time it doesn't stop when i click on the stop So to overcome this clearing timeInterval before creating a new one would result in more proper implementation