-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Parent-child update order #180
Comments
Just a quick note: would #179 make the behavior different? |
I made a possible repro: https://codesandbox.io/s/boring-pike-xp95s If this is the case, #179 is not relevant. |
Yes I think that's a proper repro of the issue |
If that’s the correct repro, I think it’s the expected behavior. The parent component render is essentially delayed. |
Got it! Thank you for answering this. |
Why is it delayed? I'm encoutering the same problem. If the parent component decides to render the child component based on some state being present how can that state not be there when checked in the child. |
Isnt this just #302 ? |
Because,
No. Zombie children can be resolved with |
I'm encountering a race condition between parent and children updates using zustand. Let me describe the problem:
I have a PrivateRoute component that redirects when my zustand currentUser state is falsy:
I have a route protected by this PrivateRoute component like so:
And then I have something like this:
I use firebase for handling auth in my app. Zustand allows me to update the state outside a react component w/c I super love:
This works well initially. But for some reason, the second time the auth state updates (i.e. a second logout), the
Home
component updates before its parentPrivateComponent
does:I solved this by passing
currentUser
instead from thePrivateComponent
:This is fine but I'm just wondering if this behavior is expected and why it seems to happen only on the second batch of auth updates.
The text was updated successfully, but these errors were encountered: