Skip to content

Commit 1d103d0

Browse files
committed
add DEV suffix to didSuspendOrError to better indicate this feature should only affect dev behavior
1 parent 237e9d2 commit 1d103d0

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

packages/react-reconciler/src/ReactFiberHydrationContext.new.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ let isHydrating: boolean = false;
8787

8888
// this flag allows for warning supression when we expect there to be mismatches due to
8989
// earlier mismatches or a suspended fiber.
90-
let didSuspendOrError: boolean = false;
90+
let didSuspendOrErrorDEV: boolean = false;
9191

9292
// Hydration errors that were thrown inside this boundary
9393
let hydrationErrors: Array<mixed> | null = null;
@@ -104,7 +104,7 @@ function warnIfHydrating() {
104104

105105
export function markDidThrowWhileHydratingDEV() {
106106
if (__DEV__) {
107-
didSuspendOrError = true;
107+
didSuspendOrErrorDEV = true;
108108
}
109109
}
110110

@@ -120,7 +120,7 @@ function enterHydrationState(fiber: Fiber): boolean {
120120
hydrationParentFiber = fiber;
121121
isHydrating = true;
122122
hydrationErrors = null;
123-
didSuspendOrError = false;
123+
didSuspendOrErrorDEV = false;
124124
return true;
125125
}
126126

@@ -138,7 +138,7 @@ function reenterHydrationStateFromDehydratedSuspenseInstance(
138138
hydrationParentFiber = fiber;
139139
isHydrating = true;
140140
hydrationErrors = null;
141-
didSuspendOrError = false;
141+
didSuspendOrErrorDEV = false;
142142
if (treeContext !== null) {
143143
restoreSuspendedTreeContext(fiber, treeContext);
144144
}
@@ -203,7 +203,7 @@ function deleteHydratableInstance(
203203

204204
function warnNonhydratedInstance(returnFiber: Fiber, fiber: Fiber) {
205205
if (__DEV__) {
206-
if (didSuspendOrError) {
206+
if (didSuspendOrErrorDEV) {
207207
// Inside a boundary that already suspended. We're currently rendering the
208208
// siblings of a suspended node. The mismatch may be due to the missing
209209
// data, so it's probably a false positive.
@@ -454,7 +454,7 @@ function prepareToHydrateHostInstance(
454454
}
455455

456456
const instance: Instance = fiber.stateNode;
457-
const shouldWarnIfMismatchDev = !didSuspendOrError;
457+
const shouldWarnIfMismatchDev = !didSuspendOrErrorDEV;
458458
const updatePayload = hydrateInstance(
459459
instance,
460460
fiber.type,
@@ -484,7 +484,7 @@ function prepareToHydrateHostTextInstance(fiber: Fiber): boolean {
484484

485485
const textInstance: TextInstance = fiber.stateNode;
486486
const textContent: string = fiber.memoizedProps;
487-
const shouldWarnIfMismatchDev = !didSuspendOrError;
487+
const shouldWarnIfMismatchDev = !didSuspendOrErrorDEV;
488488
const shouldUpdate = hydrateTextInstance(
489489
textInstance,
490490
textContent,
@@ -663,7 +663,7 @@ function resetHydrationState(): void {
663663
hydrationParentFiber = null;
664664
nextHydratableInstance = null;
665665
isHydrating = false;
666-
didSuspendOrError = false;
666+
didSuspendOrErrorDEV = false;
667667
}
668668

669669
export function upgradeHydrationErrorsToRecoverable(): void {

packages/react-reconciler/src/ReactFiberHydrationContext.old.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ let isHydrating: boolean = false;
8787

8888
// this flag allows for warning supression when we expect there to be mismatches due to
8989
// earlier mismatches or a suspended fiber.
90+
<<<<<<< packages/react-reconciler/src/ReactFiberHydrationContext.old.js
9091
let didSuspendOrError: boolean = false;
92+
=======
93+
let didSuspendOrErrorDEV: boolean = false;
94+
>>>>>>> packages/react-reconciler/src/ReactFiberHydrationContext.new.js
9195

9296
// Hydration errors that were thrown inside this boundary
9397
let hydrationErrors: Array<mixed> | null = null;
@@ -104,7 +108,11 @@ function warnIfHydrating() {
104108

105109
export function markDidThrowWhileHydratingDEV() {
106110
if (__DEV__) {
111+
<<<<<<< packages/react-reconciler/src/ReactFiberHydrationContext.old.js
107112
didSuspendOrError = true;
113+
=======
114+
didSuspendOrErrorDEV = true;
115+
>>>>>>> packages/react-reconciler/src/ReactFiberHydrationContext.new.js
108116
}
109117
}
110118

@@ -120,7 +128,11 @@ function enterHydrationState(fiber: Fiber): boolean {
120128
hydrationParentFiber = fiber;
121129
isHydrating = true;
122130
hydrationErrors = null;
131+
<<<<<<< packages/react-reconciler/src/ReactFiberHydrationContext.old.js
123132
didSuspendOrError = false;
133+
=======
134+
didSuspendOrErrorDEV = false;
135+
>>>>>>> packages/react-reconciler/src/ReactFiberHydrationContext.new.js
124136
return true;
125137
}
126138

@@ -138,7 +150,11 @@ function reenterHydrationStateFromDehydratedSuspenseInstance(
138150
hydrationParentFiber = fiber;
139151
isHydrating = true;
140152
hydrationErrors = null;
153+
<<<<<<< packages/react-reconciler/src/ReactFiberHydrationContext.old.js
141154
didSuspendOrError = false;
155+
=======
156+
didSuspendOrErrorDEV = false;
157+
>>>>>>> packages/react-reconciler/src/ReactFiberHydrationContext.new.js
142158
if (treeContext !== null) {
143159
restoreSuspendedTreeContext(fiber, treeContext);
144160
}
@@ -203,7 +219,11 @@ function deleteHydratableInstance(
203219

204220
function warnNonhydratedInstance(returnFiber: Fiber, fiber: Fiber) {
205221
if (__DEV__) {
222+
<<<<<<< packages/react-reconciler/src/ReactFiberHydrationContext.old.js
206223
if (didSuspendOrError) {
224+
=======
225+
if (didSuspendOrErrorDEV) {
226+
>>>>>>> packages/react-reconciler/src/ReactFiberHydrationContext.new.js
207227
// Inside a boundary that already suspended. We're currently rendering the
208228
// siblings of a suspended node. The mismatch may be due to the missing
209229
// data, so it's probably a false positive.
@@ -454,7 +474,11 @@ function prepareToHydrateHostInstance(
454474
}
455475

456476
const instance: Instance = fiber.stateNode;
477+
<<<<<<< packages/react-reconciler/src/ReactFiberHydrationContext.old.js
457478
const shouldWarnIfMismatchDev = !didSuspendOrError;
479+
=======
480+
const shouldWarnIfMismatchDev = !didSuspendOrErrorDEV;
481+
>>>>>>> packages/react-reconciler/src/ReactFiberHydrationContext.new.js
458482
const updatePayload = hydrateInstance(
459483
instance,
460484
fiber.type,
@@ -484,7 +508,11 @@ function prepareToHydrateHostTextInstance(fiber: Fiber): boolean {
484508

485509
const textInstance: TextInstance = fiber.stateNode;
486510
const textContent: string = fiber.memoizedProps;
511+
<<<<<<< packages/react-reconciler/src/ReactFiberHydrationContext.old.js
487512
const shouldWarnIfMismatchDev = !didSuspendOrError;
513+
=======
514+
const shouldWarnIfMismatchDev = !didSuspendOrErrorDEV;
515+
>>>>>>> packages/react-reconciler/src/ReactFiberHydrationContext.new.js
488516
const shouldUpdate = hydrateTextInstance(
489517
textInstance,
490518
textContent,
@@ -663,7 +691,11 @@ function resetHydrationState(): void {
663691
hydrationParentFiber = null;
664692
nextHydratableInstance = null;
665693
isHydrating = false;
694+
<<<<<<< packages/react-reconciler/src/ReactFiberHydrationContext.old.js
666695
didSuspendOrError = false;
696+
=======
697+
didSuspendOrErrorDEV = false;
698+
>>>>>>> packages/react-reconciler/src/ReactFiberHydrationContext.new.js
667699
}
668700

669701
export function upgradeHydrationErrorsToRecoverable(): void {

0 commit comments

Comments
 (0)