use-timer icon indicating copy to clipboard operation
use-timer copied to clipboard

Updating initial time won't update the timer

Open eddsaura opened this issue 3 years ago • 7 comments

Hey wassup,

I am changing the initial time when a state is changing ( so it should be re rendernig ) but is not updating to the new time.

The logic behind is, we have an event with start date and end date. So, when the event is not started it shows the timer to the start of the event, and when the event is running it should show the time left until the end of said event.

Also, if you are in another tab the countdown seems to stop, it could be easily fixable checking the time again, but since changing the initial time won't update it's difficult.

eddsaura avatar Dec 17 '21 11:12 eddsaura

Hey @eddsaura,

Thanks for opening this issue.

Could you create a reproductible example of this issue, for example on https://stackblitz.com/?

Thanks.

thibaultboursier avatar Dec 22 '21 16:12 thibaultboursier

Hi @thibaultboursier, I have a similar issue as @eddsaura I guess. Here's a demo: https://stackblitz.com/edit/react-dpshem?file=src/App.js

Issue 1: click "Update initial to 20", see nothing happens. Expected from my side: initialTime is set to 20. Issue 2: click "Add 20" and afterwards "Start". See 20 is added to the initial time but removed as soon as timer is started. This is for me even more critical and feels related.

What do you think?

Thanks!

sasweb avatar Mar 16 '22 00:03 sasweb

Hello @pawelsas,

Thanks for your comment and your demo. I'm going to check that.

thibaultboursier avatar Mar 17 '22 11:03 thibaultboursier

Sorry! I finally had to do it myself. Thanks for answering tho! <3

eddsaura avatar Apr 22 '22 12:04 eddsaura

same issue, any workaround?

chaoli23 avatar Jun 11 '22 02:06 chaoli23

same issue, any workaround?

This issue has been fixed on the 'develop' branch (although a reset is required before a new initialTime is reflected). Unfortunately there is no release, but I've used it without issue.

andy-todd-dev avatar Jul 06 '22 22:07 andy-todd-dev

+1. Thank you for raising, @eddsaura! Came here to discuss the same issue.

My use case is building a Pomodoro timer in React where I want to reset the timer back to various initialTime using a useState variable within the component, but noticing initialTime does not change after its initial set value.

danielrobertson avatar Jul 10 '22 02:07 danielrobertson