-
Couldn't load subscription status.
- Fork 49.7k
Try not. Do... or do not. Hydrate Suspense Boundaries. #32851
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,7 +272,10 @@ function tryHydrateText(fiber: Fiber, nextInstance: any) { | |
| return false; | ||
| } | ||
|
|
||
| function tryHydrateSuspense(fiber: Fiber, nextInstance: any) { | ||
| function tryHydrateSuspense( | ||
| fiber: Fiber, | ||
| nextInstance: any, | ||
| ): null | SuspenseInstance { | ||
| // fiber is a SuspenseComponent Fiber | ||
| const suspenseInstance = canHydrateSuspenseInstance( | ||
| nextInstance, | ||
|
|
@@ -298,9 +301,8 @@ function tryHydrateSuspense(fiber: Fiber, nextInstance: any) { | |
| // While a Suspense Instance does have children, we won't step into | ||
| // it during the first pass. Instead, we'll reenter it later. | ||
| nextHydratableInstance = null; | ||
| return true; | ||
| } | ||
| return false; | ||
| return suspenseInstance; | ||
| } | ||
|
|
||
| export const HydrationMismatchException: mixed = new Error( | ||
|
|
@@ -423,15 +425,16 @@ function tryToClaimNextHydratableTextInstance(fiber: Fiber): void { | |
| } | ||
| } | ||
|
|
||
| function tryToClaimNextHydratableSuspenseInstance(fiber: Fiber): void { | ||
| if (!isHydrating) { | ||
| return; | ||
| } | ||
| function claimNextHydratableSuspenseInstance(fiber: Fiber): SuspenseInstance { | ||
| const nextInstance = nextHydratableInstance; | ||
| if (!nextInstance || !tryHydrateSuspense(fiber, nextInstance)) { | ||
| const suspenseInstance = nextInstance | ||
| ? tryHydrateSuspense(fiber, nextInstance) | ||
| : null; | ||
| if (suspenseInstance === null) { | ||
| warnNonHydratedInstance(fiber, nextInstance); | ||
| throwOnHydrationMismatch(fiber); | ||
| throw throwOnHydrationMismatch(fiber); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Satisfies Flow. Does Flow not have something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It didn't work |
||
| } | ||
| return suspenseInstance; | ||
| } | ||
|
|
||
| export function tryToClaimNextHydratableFormMarkerInstance( | ||
|
|
@@ -790,7 +793,7 @@ export { | |
| claimHydratableSingleton, | ||
| tryToClaimNextHydratableInstance, | ||
| tryToClaimNextHydratableTextInstance, | ||
| tryToClaimNextHydratableSuspenseInstance, | ||
| claimNextHydratableSuspenseInstance, | ||
| prepareToHydrateHostInstance, | ||
| prepareToHydrateHostTextInstance, | ||
| prepareToHydrateHostSuspenseInstance, | ||
|
|
||
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.
This code path became unreachable once we started throwing for all hydration mismatches but we didn't know that due to the code structure.