Skip to content

Commit dcc2675

Browse files
committed
Simplify duplication a bit
1 parent 5901d65 commit dcc2675

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
@@ -399,13 +399,7 @@ function tryToClaimNextHydratableInstance(fiber: Fiber): void {
399399
);
400400

401401
const nextInstance = nextHydratableInstance;
402-
if (!nextInstance) {
403-
if (shouldKeepWarning) {
404-
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
405-
}
406-
throwOnHydrationMismatch(fiber);
407-
}
408-
if (!tryHydrateInstance(fiber, nextInstance)) {
402+
if (!nextInstance || !tryHydrateInstance(fiber, nextInstance)) {
409403
if (shouldKeepWarning) {
410404
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
411405
}
@@ -425,15 +419,7 @@ function tryToClaimNextHydratableTextInstance(fiber: Fiber): void {
425419
shouldKeepWarning = validateHydratableTextInstance(text, currentHostContext);
426420

427421
const nextInstance = nextHydratableInstance;
428-
if (!nextInstance) {
429-
// We exclude non hydrabable text because we know there are no matching hydratables.
430-
// We either throw or insert depending on the render mode.
431-
if (shouldKeepWarning) {
432-
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
433-
}
434-
throwOnHydrationMismatch(fiber);
435-
}
436-
if (!tryHydrateText(fiber, nextInstance)) {
422+
if (!nextInstance || !tryHydrateText(fiber, nextInstance)) {
437423
if (shouldKeepWarning) {
438424
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
439425
}
@@ -446,11 +432,7 @@ function tryToClaimNextHydratableSuspenseInstance(fiber: Fiber): void {
446432
return;
447433
}
448434
const nextInstance = nextHydratableInstance;
449-
if (!nextInstance) {
450-
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
451-
throwOnHydrationMismatch(fiber);
452-
}
453-
if (!tryHydrateSuspense(fiber, nextInstance)) {
435+
if (!nextInstance || !tryHydrateSuspense(fiber, nextInstance)) {
454436
warnNonHydratedInstance((hydrationParentFiber: any), fiber);
455437
throwOnHydrationMismatch(fiber);
456438
}

0 commit comments

Comments
 (0)