Closed pawelkrystkiewicz closed 2 years ago
Hey, this behaviour is specific to how setTimeout
is working (browser don't guarantee that setTimeout for 2000ms will actually trigger callback after exactly 2000ms). If you want self correcting timer take a look at https://github.com/minwork/react-interval-hook
threshold
bugHi, I found out that passed threshold value is not being observed correctly by the hook. It triggers end at about 85% time elapsed. I set my button timer to 2000ms and it got triggered around 1710 to 1750 (it is not constant)
In my code I needed to add this hack:
How to get time left?
Besides that it would be ideal if I could get my hand on value of time left from the hook. Is it possible? My use case is that I'm showing how much time left by progress bar around button