thibaultboursier / use-timer

A timer hook for React
MIT License
198 stars 24 forks source link

Timer continues counting when paused #88

Closed Krastiy13 closed 6 months ago

Krastiy13 commented 6 months ago

The Timer component utilizes react-timer-hook to manage a countdown timer. The issue occurs when pausing the timer using the provided pause button. Despite visually appearing paused, the internal timer continues to count down, resulting in incorrect time tracking.

`const { time, correctMode, onTimeExpired, onStopTime, setTimeLeft } = props; const expiryTimestamp = new Date(Date.now() + time); const { seconds, minutes, hours, pause, resume, isRunning } = useTimer({ expiryTimestamp, onExpire: () => { onTimeExpired(); onStopTime(); },

}); const [expanded, setExpanded] = useState(true);

const togglePause = () => { isRunning ? pause() : resume() }

useEffect(() => { setTimeLeft((3600000 hours) + (60000 minutes) + (1000 * seconds)) }, [seconds, minutes, hours]);`

thibaultboursier commented 6 months ago

Hello @Krastiy13,

You talked about an other library, not use-timer ;-)