Skip to content

Commit 06a3ee6

Browse files
committed
Simplify duplication a bit
1 parent 630ceb8 commit 06a3ee6

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

packages/react-reconciler/src/ReactFiberHydrationContext.js

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,7 @@ function tryToClaimNextHydratableInstance(fiber: Fiber): void {
406406
);
407407

408408
const nextInstance = nextHydratableInstance;
409-
if (!nextInstance) {
410-
if (shouldKeepWarning) {
411-
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
412-
}
413-
throwOnHydrationMismatch(fiber);
414-
}
415-
if (!tryHydrateInstance(fiber, nextInstance)) {
409+
if (!nextInstance || !tryHydrateInstance(fiber, nextInstance)) {
416410
if (shouldKeepWarning) {
417411
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
418412
}
@@ -432,15 +426,7 @@ function tryToClaimNextHydratableTextInstance(fiber: Fiber): void {
432426
shouldKeepWarning = validateHydratableTextInstance(text, currentHostContext);
433427

434428
const nextInstance = nextHydratableInstance;
435-
if (!nextInstance) {
436-
// We exclude non hydrabable text because we know there are no matching hydratables.
437-
// We either throw or insert depending on the render mode.
438-
if (shouldKeepWarning) {
439-
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
440-
}
441-
throwOnHydrationMismatch(fiber);
442-
}
443-
if (!tryHydrateText(fiber, nextInstance)) {
429+
if (!nextInstance || !tryHydrateText(fiber, nextInstance)) {
444430
if (shouldKeepWarning) {
445431
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
446432
}
@@ -453,11 +439,7 @@ function tryToClaimNextHydratableSuspenseInstance(fiber: Fiber): void {
453439
return;
454440
}
455441
const nextInstance = nextHydratableInstance;
456-
if (!nextInstance) {
457-
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
458-
throwOnHydrationMismatch(fiber);
459-
}
460-
if (!tryHydrateSuspense(fiber, nextInstance)) {
442+
if (!nextInstance || !tryHydrateSuspense(fiber, nextInstance)) {
461443
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
462444
throwOnHydrationMismatch(fiber);
463445
}

0 commit comments

Comments
 (0)