-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
restart Function not working as Expected #70
Comments
Hi @prpercival, did you make any progress with this? I have the same issue and want to restart the timer after it has expired. Interestingly, the 'restart' button in the official demo site does reset+start the 10 minute timer after first expiry. Also, the onExpire does not seem to be doing anything strange. |
@erikcvisser After playing around with it, I found that the timer will only restart if you re-render the component your timer is in when updating the time. Not an ideal solution, but it enabled me to reset the timer. |
use setTimeout() setTimeout(() => { |
@sjwen98 easy but effective - thanks! |
one more solution (when restart func called outside of onExpire callback it works fine):
|
Any hope of this getting patched sometime soon? While there are ways to hack around this its frustrating to have to do it to begin with. |
Hello, I solved this problem like this: export const TimerSixtySecond = ({ expiryTimestamp }) => { const { return ( ); |
As @prpercival said, it's only going to restart the timer if the component is re-rendered.
|
Still happening in 2023, boolean state flip works as a workaround 👍 |
The setTimeout() mentioned above is an easy work around! |
Quite disappointing, despite the workarounds above solving the issue. |
If I call restart after the timer has already expired, the timer updates to the new Date but it doesn't start counting down.
Simple Example:
The text was updated successfully, but these errors were encountered: