-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
Is it possible to set the current step to state? #282
Comments
I'm using it in a function component and this works for me |
Hi. I experienced that too. IMO the problem is that the |
A workaround for this is setting a timout function You can see here, why this works: https://www.gitmemory.com/issue/Paratron/hookrouter/110/604592927 |
When you have const stateA = { foo: 1 };
const stateB = { foo: 1 };
stateA === stateB; // false, consider a state change
stateA.foo === stateB.foo; // true, state is the same In other words, to prevent triggering a state change, compare getCurrentStep={curr =>
setState(prevState => prevState.currentStep !== curr ? { currentStep:curr } : prevState)
} Essentially : if |
If I do something like this:
getCurrentStep={curr => setState({ currentStep: curr })}
I get an error saying: "Cannot update a component from inside the function body of a different component"
Is there any way of setting the current step number to a state variable?
The text was updated successfully, but these errors were encountered: