Skip to content

Commit 029fdce

Browse files
authored
root.hydrate -> root.isDehydrated (#22420)
I think this naming is a bit clearer. It means the root is currently showing server rendered content that needs to be hydrated. A dehydrated root is conceptually the same as what we call dehydrated Suspense boundary, so this makes the naming of the root align with the naming of subtrees.
1 parent 1c73cee commit 029fdce

15 files changed

+27
-27
lines changed

Diff for: packages/react-dom/src/events/ReactDOMEventListener.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export function attemptToDispatchEvent(
264264
targetInst = null;
265265
} else if (tag === HostRoot) {
266266
const root: FiberRoot = nearestMounted.stateNode;
267-
if (root.hydrate) {
267+
if (root.isDehydrated) {
268268
// If this happens during a replay something went wrong and it might block
269269
// the whole system.
270270
return getContainerFromFiber(nearestMounted);

Diff for: packages/react-dom/src/events/ReactDOMEventReplaying.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ function attemptExplicitHydrationTarget(
399399
}
400400
} else if (tag === HostRoot) {
401401
const root: FiberRoot = nearestMounted.stateNode;
402-
if (root.hydrate) {
402+
if (root.isDehydrated) {
403403
queuedTarget.blockedOn = getContainerFromFiber(nearestMounted);
404404
// We don't currently have a way to increase the priority of
405405
// a root other than sync.

Diff for: packages/react-reconciler/src/ReactFiberBeginWork.new.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ function updateHostRoot(current, workInProgress, renderLanes) {
12951295
resetHydrationState();
12961296
return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
12971297
}
1298-
if (root.hydrate && enterHydrationState(workInProgress)) {
1298+
if (root.isDehydrated && enterHydrationState(workInProgress)) {
12991299
// If we don't have any current children this might be the first pass.
13001300
// We always try to hydrate. If this isn't a hydration pass there won't
13011301
// be any children to hydrate which is effectively the same thing as

Diff for: packages/react-reconciler/src/ReactFiberBeginWork.old.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ function updateHostRoot(current, workInProgress, renderLanes) {
12951295
resetHydrationState();
12961296
return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
12971297
}
1298-
if (root.hydrate && enterHydrationState(workInProgress)) {
1298+
if (root.isDehydrated && enterHydrationState(workInProgress)) {
12991299
// If we don't have any current children this might be the first pass.
13001300
// We always try to hydrate. If this isn't a hydration pass there won't
13011301
// be any children to hydrate which is effectively the same thing as

Diff for: packages/react-reconciler/src/ReactFiberCommitWork.new.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1827,9 +1827,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
18271827
case HostRoot: {
18281828
if (supportsHydration) {
18291829
const root: FiberRoot = finishedWork.stateNode;
1830-
if (root.hydrate) {
1830+
if (root.isDehydrated) {
18311831
// We've just hydrated. No need to hydrate again.
1832-
root.hydrate = false;
1832+
root.isDehydrated = false;
18331833
commitHydratedContainer(root.containerInfo);
18341834
}
18351835
}
@@ -1933,9 +1933,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
19331933
case HostRoot: {
19341934
if (supportsHydration) {
19351935
const root: FiberRoot = finishedWork.stateNode;
1936-
if (root.hydrate) {
1936+
if (root.isDehydrated) {
19371937
// We've just hydrated. No need to hydrate again.
1938-
root.hydrate = false;
1938+
root.isDehydrated = false;
19391939
commitHydratedContainer(root.containerInfo);
19401940
}
19411941
}

Diff for: packages/react-reconciler/src/ReactFiberCommitWork.old.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1827,9 +1827,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
18271827
case HostRoot: {
18281828
if (supportsHydration) {
18291829
const root: FiberRoot = finishedWork.stateNode;
1830-
if (root.hydrate) {
1830+
if (root.isDehydrated) {
18311831
// We've just hydrated. No need to hydrate again.
1832-
root.hydrate = false;
1832+
root.isDehydrated = false;
18331833
commitHydratedContainer(root.containerInfo);
18341834
}
18351835
}
@@ -1933,9 +1933,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
19331933
case HostRoot: {
19341934
if (supportsHydration) {
19351935
const root: FiberRoot = finishedWork.stateNode;
1936-
if (root.hydrate) {
1936+
if (root.isDehydrated) {
19371937
// We've just hydrated. No need to hydrate again.
1938-
root.hydrate = false;
1938+
root.isDehydrated = false;
19391939
commitHydratedContainer(root.containerInfo);
19401940
}
19411941
}

Diff for: packages/react-reconciler/src/ReactFiberCompleteWork.new.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ function completeWork(
867867
// If we hydrated, then we'll need to schedule an update for
868868
// the commit side-effects on the root.
869869
markUpdate(workInProgress);
870-
} else if (!fiberRoot.hydrate) {
870+
} else if (!fiberRoot.isDehydrated) {
871871
// Schedule an effect to clear this container at the start of the next commit.
872872
// This handles the case of React rendering into a container with previous children.
873873
// It's also safe to do for updates too, because current.child would only be null

Diff for: packages/react-reconciler/src/ReactFiberCompleteWork.old.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ function completeWork(
867867
// If we hydrated, then we'll need to schedule an update for
868868
// the commit side-effects on the root.
869869
markUpdate(workInProgress);
870-
} else if (!fiberRoot.hydrate) {
870+
} else if (!fiberRoot.isDehydrated) {
871871
// Schedule an effect to clear this container at the start of the next commit.
872872
// This handles the case of React rendering into a container with previous children.
873873
// It's also safe to do for updates too, because current.child would only be null

Diff for: packages/react-reconciler/src/ReactFiberReconciler.new.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ export function attemptSynchronousHydration(fiber: Fiber): void {
353353
switch (fiber.tag) {
354354
case HostRoot:
355355
const root: FiberRoot = fiber.stateNode;
356-
if (root.hydrate) {
356+
if (root.isDehydrated) {
357357
// Flush the first scheduled "update".
358358
const lanes = getHighestPriorityPendingLanes(root);
359359
flushRoot(root, lanes);

Diff for: packages/react-reconciler/src/ReactFiberReconciler.old.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ export function attemptSynchronousHydration(fiber: Fiber): void {
353353
switch (fiber.tag) {
354354
case HostRoot:
355355
const root: FiberRoot = fiber.stateNode;
356-
if (root.hydrate) {
356+
if (root.isDehydrated) {
357357
// Flush the first scheduled "update".
358358
const lanes = getHighestPriorityPendingLanes(root);
359359
flushRoot(root, lanes);

Diff for: packages/react-reconciler/src/ReactFiberRoot.new.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function FiberRootNode(containerInfo, tag, hydrate) {
3939
this.timeoutHandle = noTimeout;
4040
this.context = null;
4141
this.pendingContext = null;
42-
this.hydrate = hydrate;
42+
this.isDehydrated = hydrate;
4343
this.callbackNode = null;
4444
this.callbackPriority = NoLane;
4545
this.eventTimes = createLaneMap(NoLanes);

Diff for: packages/react-reconciler/src/ReactFiberRoot.old.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function FiberRootNode(containerInfo, tag, hydrate) {
3939
this.timeoutHandle = noTimeout;
4040
this.context = null;
4141
this.pendingContext = null;
42-
this.hydrate = hydrate;
42+
this.isDehydrated = hydrate;
4343
this.callbackNode = null;
4444
this.callbackPriority = NoLane;
4545
this.eventTimes = createLaneMap(NoLanes);

Diff for: packages/react-reconciler/src/ReactFiberWorkLoop.new.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,8 @@ function recoverFromConcurrentError(root, errorRetryLanes) {
859859

860860
// If an error occurred during hydration, discard server response and fall
861861
// back to client side render.
862-
if (root.hydrate) {
863-
root.hydrate = false;
862+
if (root.isDehydrated) {
863+
root.isDehydrated = false;
864864
if (__DEV__) {
865865
errorHydratingContainer(root.containerInfo);
866866
}
@@ -1076,8 +1076,8 @@ function performSyncWorkOnRoot(root) {
10761076

10771077
// If an error occurred during hydration,
10781078
// discard server response and fall back to client side render.
1079-
if (root.hydrate) {
1080-
root.hydrate = false;
1079+
if (root.isDehydrated) {
1080+
root.isDehydrated = false;
10811081
if (__DEV__) {
10821082
errorHydratingContainer(root.containerInfo);
10831083
}

Diff for: packages/react-reconciler/src/ReactFiberWorkLoop.old.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,8 @@ function recoverFromConcurrentError(root, errorRetryLanes) {
859859

860860
// If an error occurred during hydration, discard server response and fall
861861
// back to client side render.
862-
if (root.hydrate) {
863-
root.hydrate = false;
862+
if (root.isDehydrated) {
863+
root.isDehydrated = false;
864864
if (__DEV__) {
865865
errorHydratingContainer(root.containerInfo);
866866
}
@@ -1076,8 +1076,8 @@ function performSyncWorkOnRoot(root) {
10761076

10771077
// If an error occurred during hydration,
10781078
// discard server response and fall back to client side render.
1079-
if (root.hydrate) {
1080-
root.hydrate = false;
1079+
if (root.isDehydrated) {
1080+
root.isDehydrated = false;
10811081
if (__DEV__) {
10821082
errorHydratingContainer(root.containerInfo);
10831083
}

Diff for: packages/react-reconciler/src/ReactInternalTypes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ type BaseFiberRootProperties = {|
212212
context: Object | null,
213213
pendingContext: Object | null,
214214
// Determines if we should attempt to hydrate on the initial mount
215-
+hydrate: boolean,
215+
+isDehydrated: boolean,
216216

217217
// Used by useMutableSource hook to avoid tearing during hydration.
218218
mutableSourceEagerHydrationData?: Array<

0 commit comments

Comments
 (0)