-
Notifications
You must be signed in to change notification settings - Fork 50.2k
Fix form status reset when component state is updated #34075
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
Conversation
|
Comparing: eb89912...aa288b5 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
| // This is intentionally set here instead of pushHostContext because | ||
| // pushHostContext gets called before we process the state hook, to avoid | ||
| // a state mismatch in the event that something suspends. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I fully understand this comment. If something suspends we pop back up. And the Component we're rendering (here: TransitionAwareHostComponent) should not be able to read the current Context just yet which is what pushing the context before the render would do, right? We can't nest Host Context anyway though. So this seems safe to move the push after the render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A common issue is that CompleteWork and UnwindWork unconditionally calls popHostContext. That's called even when something in the component suspends because it doesn't know if we suspended before or after the push. There's no state to indicate that.
That's why we always pushHostContext and other push things immediately when we enter the update before anything could error or suspend.
Since renderTransitionAwareHostComponentWithHooks might suspend, I don't think it's safe to move the pushHostContext after it. In fact I'm surprised we don't have a test that fails for that case. Maybe we're lacking coverage or there's some other thing that covers it but it shouldn't be safe in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Moved the pushContext back to its original place. When the state changes, we update the context value which works because only a single transition provider is allowed.
Basically, we set the value on pushHostContext and when we update state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert this comment back to the original now too please?
b6348c2 to
77dc8cc
Compare
77dc8cc to
9be8342
Compare
a8e8216 to
692d5d9
Compare
|
Would love to see this merged in soon. We're blocked from upgrading to Next 15 and React 19 until this issue is fixed - will also have to wait for Next to pull in a new canary release after this is merged. @sebmarkbage any chance you could review the most recent changes? |
692d5d9 to
aa288b5
Compare
Co-authored-by: Vordgi <sasha2822222@gmail.com> DiffTrain build for [8ac5f4e](facebook@8ac5f4e)
Co-authored-by: Vordgi <sasha2822222@gmail.com> DiffTrain build for [8ac5f4e](facebook@8ac5f4e)
Alternate to #33351 without the regression highlighted in #33351 (comment)
Host context is now updated in
pushHostContext(similar to normal React Context) in addition to duringupdateHostComponent.Closes #30368
Closes #33351