Not changing initialTime dynamically
Hi, I'm trying to increment/decrement timer minutes using a state propety
this.state = {
....
minutes: 5,
....
};
render() {
return (
<Timer initialTime={this.state.minutes * 60000}>
<Timer.Minutes/>:<Timer.Seconds/>
</Timer>
)
}
But when I trigger a function to update state, It's not changing the value in Timer.
@Jromero97 same issue, do you have any solution?
You should use "setTime"
see "Change props dynamically and use HOC" section https://volkov97.github.io/react-compound-timer/
by the way, now you can use "useTimer" hook - it should be more convenient then
Here you can see an example, which uses "setTime" from a hook
It sets timer time to 5000, after 3000 ms after mounting
https://codesandbox.io/s/elated-sutherland-6flom?fontsize=14
@volkov97 it works when startImmediately: true but when I startImmediately: false it does not work.
Is there a solution that I can startImmediately: false and use setTime together?
@volkov97 can I use setTime even without hooks? I'm using 1.0 version. Is there a way for me to reset the initialTime to 0 when I'm changing the value of the time because I need to save its value and then continue again and when I click reset, I need to set the value of the time back to 0. But it resets to the last initialTime.