Closed jmaricic closed 5 years ago
@jmaricic You have to pass a new until value to the component, you can do this in onFinish callback, once the timer finished you assign a new until value to the global state that until value came from. Like if your until value came from the parent component state, in onFinish callback you reset that value, or if your until value came from redux reducer you need to dispatch an action to update that value. I think this should do the trick for you.
I have a global state in my component, and I've set it to 0 like this:
state = { counter: 0, };
And when I press the button I'm calling a setState:
this.setState({ counter: 59 });
And this is what the countdown looks like:
<CountDown style={{ marginBottom: 30 }} until={this.state.counter} timeToShow={['S']} size={30} />
The problem is, my component is receiving props every 5 settings and I don't want the counter to reset on every prop received... Is there a way to achieve that?
@jmaricic I got your point I have pushed a fix at bfcf2a6bc21cff4b55ecc9cfc353831a5ca7f7d8 and published as 1.7.3 Thanks
Hi, I tried to reset the timer, and yes... the timer gets a new until value when the countdown finishes, but it won't start counting down again.
hi,
i have the same problem @aldocano29 , any solution ?
if you still have the problem, this solution it work for me:
it is a temporally solution.
@Tatandiaz13 @aldocano29 Will push fix soon
@Tatandiaz13 @aldocano29 this should be fixed with a4140c78f01ff55a0125238bab96e6e69442a76d But if you pass a same last until value after the counter has finished it wont get restarted
@talalmajali But if I need to pass the same value again? I'm doing a counter for a quiz and I need to reset the counter once the answer was saved.
Is there a way to restart a timer once the countdown is finished or to manually start the countdown (on button press for example)?