Skip to content

Commit

Permalink
Simplify duplication a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Mar 26, 2024
1 parent 24687d9 commit da2de86
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions packages/react-reconciler/src/ReactFiberHydrationContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,7 @@ function tryToClaimNextHydratableInstance(fiber: Fiber): void {
);

const nextInstance = nextHydratableInstance;
if (!nextInstance) {
if (shouldKeepWarning) {
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
}
throwOnHydrationMismatch(fiber);
}
if (!tryHydrateInstance(fiber, nextInstance)) {
if (!nextInstance || !tryHydrateInstance(fiber, nextInstance)) {
if (shouldKeepWarning) {
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
}
Expand All @@ -425,15 +419,7 @@ function tryToClaimNextHydratableTextInstance(fiber: Fiber): void {
shouldKeepWarning = validateHydratableTextInstance(text, currentHostContext);

const nextInstance = nextHydratableInstance;
if (!nextInstance) {
// We exclude non hydrabable text because we know there are no matching hydratables.
// We either throw or insert depending on the render mode.
if (shouldKeepWarning) {
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
}
throwOnHydrationMismatch(fiber);
}
if (!tryHydrateText(fiber, nextInstance)) {
if (!nextInstance || !tryHydrateText(fiber, nextInstance)) {
if (shouldKeepWarning) {
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
}
Expand All @@ -446,11 +432,7 @@ function tryToClaimNextHydratableSuspenseInstance(fiber: Fiber): void {
return;
}
const nextInstance = nextHydratableInstance;
if (!nextInstance) {
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
throwOnHydrationMismatch(fiber);
}
if (!tryHydrateSuspense(fiber, nextInstance)) {
if (!nextInstance || !tryHydrateSuspense(fiber, nextInstance)) {
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
throwOnHydrationMismatch(fiber);
}
Expand Down

0 comments on commit da2de86

Please sign in to comment.