Skip to content

Commit

Permalink
add DEV suffix to didSuspendOrError to better indicate this feature s…
Browse files Browse the repository at this point in the history
…hould only affect dev behavior
  • Loading branch information
gnoff committed Apr 20, 2022
1 parent 237e9d2 commit f3cdd36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions packages/react-reconciler/src/ReactFiberHydrationContext.new.js
Expand Up @@ -87,7 +87,7 @@ let isHydrating: boolean = false;

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

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

export function markDidThrowWhileHydratingDEV() {
if (__DEV__) {
didSuspendOrError = true;
didSuspendOrErrorDEV = true;
}
}

Expand All @@ -120,7 +120,7 @@ function enterHydrationState(fiber: Fiber): boolean {
hydrationParentFiber = fiber;
isHydrating = true;
hydrationErrors = null;
didSuspendOrError = false;
didSuspendOrErrorDEV = false;
return true;
}

Expand All @@ -138,7 +138,7 @@ function reenterHydrationStateFromDehydratedSuspenseInstance(
hydrationParentFiber = fiber;
isHydrating = true;
hydrationErrors = null;
didSuspendOrError = false;
didSuspendOrErrorDEV = false;
if (treeContext !== null) {
restoreSuspendedTreeContext(fiber, treeContext);
}
Expand Down Expand Up @@ -203,7 +203,7 @@ function deleteHydratableInstance(

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

const instance: Instance = fiber.stateNode;
const shouldWarnIfMismatchDev = !didSuspendOrError;
const shouldWarnIfMismatchDev = !didSuspendOrErrorDEV;
const updatePayload = hydrateInstance(
instance,
fiber.type,
Expand Down Expand Up @@ -484,7 +484,7 @@ function prepareToHydrateHostTextInstance(fiber: Fiber): boolean {

const textInstance: TextInstance = fiber.stateNode;
const textContent: string = fiber.memoizedProps;
const shouldWarnIfMismatchDev = !didSuspendOrError;
const shouldWarnIfMismatchDev = !didSuspendOrErrorDEV;
const shouldUpdate = hydrateTextInstance(
textInstance,
textContent,
Expand Down Expand Up @@ -663,7 +663,7 @@ function resetHydrationState(): void {
hydrationParentFiber = null;
nextHydratableInstance = null;
isHydrating = false;
didSuspendOrError = false;
didSuspendOrErrorDEV = false;
}

export function upgradeHydrationErrorsToRecoverable(): void {
Expand Down
16 changes: 8 additions & 8 deletions packages/react-reconciler/src/ReactFiberHydrationContext.old.js
Expand Up @@ -87,7 +87,7 @@ let isHydrating: boolean = false;

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

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

export function markDidThrowWhileHydratingDEV() {
if (__DEV__) {
didSuspendOrError = true;
didSuspendOrErrorDEV = true;
}
}

Expand All @@ -120,7 +120,7 @@ function enterHydrationState(fiber: Fiber): boolean {
hydrationParentFiber = fiber;
isHydrating = true;
hydrationErrors = null;
didSuspendOrError = false;
didSuspendOrErrorDEV = false;
return true;
}

Expand All @@ -138,7 +138,7 @@ function reenterHydrationStateFromDehydratedSuspenseInstance(
hydrationParentFiber = fiber;
isHydrating = true;
hydrationErrors = null;
didSuspendOrError = false;
didSuspendOrErrorDEV = false;
if (treeContext !== null) {
restoreSuspendedTreeContext(fiber, treeContext);
}
Expand Down Expand Up @@ -203,7 +203,7 @@ function deleteHydratableInstance(

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

const instance: Instance = fiber.stateNode;
const shouldWarnIfMismatchDev = !didSuspendOrError;
const shouldWarnIfMismatchDev = !didSuspendOrErrorDEV;
const updatePayload = hydrateInstance(
instance,
fiber.type,
Expand Down Expand Up @@ -484,7 +484,7 @@ function prepareToHydrateHostTextInstance(fiber: Fiber): boolean {

const textInstance: TextInstance = fiber.stateNode;
const textContent: string = fiber.memoizedProps;
const shouldWarnIfMismatchDev = !didSuspendOrError;
const shouldWarnIfMismatchDev = !didSuspendOrErrorDEV;
const shouldUpdate = hydrateTextInstance(
textInstance,
textContent,
Expand Down Expand Up @@ -663,7 +663,7 @@ function resetHydrationState(): void {
hydrationParentFiber = null;
nextHydratableInstance = null;
isHydrating = false;
didSuspendOrError = false;
didSuspendOrErrorDEV = false;
}

export function upgradeHydrationErrorsToRecoverable(): void {
Expand Down

0 comments on commit f3cdd36

Please sign in to comment.