talalmajali / react-native-countdown-component

React Native CountDown
MIT License
264 stars 233 forks source link

how can i reset until #92

Closed jimkhan closed 3 years ago

jimkhan commented 3 years ago

i want to reset the unitl value how can I do it?? is there any solution? thanks in advance!

ManhVuTien commented 3 years ago

=

i want to reset the unitl value how can I do it?? is there any solution? thanks in advance!

Do you have a solution?

memanoj commented 1 year ago

Try this with new id it will reset the timer and it should be in string

<CountDown id={new Date().getTime().toString()}

Reset Timer

BogdanGeorgian91 commented 1 year ago

more specifically how does it work? what do you do after adding that?

MrMicrowaveOven commented 5 months ago

@BogdanGeorgian91 I just figured this out. Sorry I'm 8 months late.

To reset the timer, you must change the id of the CountDown. In other words, if I set the id to 1, updating the id to 2 will reset the counter to whatever's in the until prop.

I was able to add a "Reset Timer" button that would randomize the state of the id, so it would reset every time the button was pressed. I had the id saved using setState, with a resetTimer method that would set the id to a random number.

Let me know if that makes sense. It's not even mentioned in the docs.