@samitouri / QOS-React-2 / commits / 029fdcebbf

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.

Andrew Clark committed Sep 24, 2021 at 13:45 UTC 029fdcebbfec51a28af27cd390dff8668bf136cf
15 files changed +27 -27
packages/react-dom/src/events/ReactDOMEventListener.js
+1 -1
@@ -264,7 +264,7 @@ export function attemptToDispatchEvent(
264 targetInst = null;
265 } else if (tag === HostRoot) {
266 const root: FiberRoot = nearestMounted.stateNode;
267 - if (root.hydrate) {
267 + if (root.isDehydrated) {
268 // If this happens during a replay something went wrong and it might block
269 // the whole system.
270 return getContainerFromFiber(nearestMounted);
packages/react-dom/src/events/ReactDOMEventReplaying.js
+1 -1
@@ -399,7 +399,7 @@ function attemptExplicitHydrationTarget(
399 }
400 } else if (tag === HostRoot) {
401 const root: FiberRoot = nearestMounted.stateNode;
402 - if (root.hydrate) {
402 + if (root.isDehydrated) {
403 queuedTarget.blockedOn = getContainerFromFiber(nearestMounted);
404 // We don't currently have a way to increase the priority of
405 // a root other than sync.
packages/react-reconciler/src/ReactFiberBeginWork.new.js
+1 -1
@@ -1295,7 +1295,7 @@ function updateHostRoot(current, workInProgress, renderLanes) {
1295 resetHydrationState();
1296 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
1297 }
1298 - if (root.hydrate && enterHydrationState(workInProgress)) {
1298 + if (root.isDehydrated && enterHydrationState(workInProgress)) {
1299 // If we don't have any current children this might be the first pass.
1300 // We always try to hydrate. If this isn't a hydration pass there won't
1301 // be any children to hydrate which is effectively the same thing as
packages/react-reconciler/src/ReactFiberBeginWork.old.js
+1 -1
@@ -1295,7 +1295,7 @@ function updateHostRoot(current, workInProgress, renderLanes) {
1295 resetHydrationState();
1296 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
1297 }
1298 - if (root.hydrate && enterHydrationState(workInProgress)) {
1298 + if (root.isDehydrated && enterHydrationState(workInProgress)) {
1299 // If we don't have any current children this might be the first pass.
1300 // We always try to hydrate. If this isn't a hydration pass there won't
1301 // be any children to hydrate which is effectively the same thing as
packages/react-reconciler/src/ReactFiberCommitWork.new.js
+4 -4
@@ -1827,9 +1827,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
1827 case HostRoot: {
1828 if (supportsHydration) {
1829 const root: FiberRoot = finishedWork.stateNode;
1830 - if (root.hydrate) {
1830 + if (root.isDehydrated) {
1831 // We've just hydrated. No need to hydrate again.
1832 - root.hydrate = false;
1832 + root.isDehydrated = false;
1833 commitHydratedContainer(root.containerInfo);
1834 }
1835 }
@@ -1933,9 +1933,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
1933 case HostRoot: {
1934 if (supportsHydration) {
1935 const root: FiberRoot = finishedWork.stateNode;
1936 - if (root.hydrate) {
1936 + if (root.isDehydrated) {
1937 // We've just hydrated. No need to hydrate again.
1938 - root.hydrate = false;
1938 + root.isDehydrated = false;
1939 commitHydratedContainer(root.containerInfo);
1940 }
1941 }
packages/react-reconciler/src/ReactFiberCommitWork.old.js
+4 -4
@@ -1827,9 +1827,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
1827 case HostRoot: {
1828 if (supportsHydration) {
1829 const root: FiberRoot = finishedWork.stateNode;
1830 - if (root.hydrate) {
1830 + if (root.isDehydrated) {
1831 // We've just hydrated. No need to hydrate again.
1832 - root.hydrate = false;
1832 + root.isDehydrated = false;
1833 commitHydratedContainer(root.containerInfo);
1834 }
1835 }
@@ -1933,9 +1933,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
1933 case HostRoot: {
1934 if (supportsHydration) {
1935 const root: FiberRoot = finishedWork.stateNode;
1936 - if (root.hydrate) {
1936 + if (root.isDehydrated) {
1937 // We've just hydrated. No need to hydrate again.
1938 - root.hydrate = false;
1938 + root.isDehydrated = false;
1939 commitHydratedContainer(root.containerInfo);
1940 }
1941 }
packages/react-reconciler/src/ReactFiberCompleteWork.new.js
+1 -1
@@ -867,7 +867,7 @@ function completeWork(
867 // If we hydrated, then we'll need to schedule an update for
868 // the commit side-effects on the root.
869 markUpdate(workInProgress);
870 - } else if (!fiberRoot.hydrate) {
870 + } else if (!fiberRoot.isDehydrated) {
871 // Schedule an effect to clear this container at the start of the next commit.
872 // This handles the case of React rendering into a container with previous children.
873 // It's also safe to do for updates too, because current.child would only be null
packages/react-reconciler/src/ReactFiberCompleteWork.old.js
+1 -1
@@ -867,7 +867,7 @@ function completeWork(
867 // If we hydrated, then we'll need to schedule an update for
868 // the commit side-effects on the root.
869 markUpdate(workInProgress);
870 - } else if (!fiberRoot.hydrate) {
870 + } else if (!fiberRoot.isDehydrated) {
871 // Schedule an effect to clear this container at the start of the next commit.
872 // This handles the case of React rendering into a container with previous children.
873 // It's also safe to do for updates too, because current.child would only be null
packages/react-reconciler/src/ReactFiberReconciler.new.js
+1 -1
@@ -353,7 +353,7 @@ export function attemptSynchronousHydration(fiber: Fiber): void {
353 switch (fiber.tag) {
354 case HostRoot:
355 const root: FiberRoot = fiber.stateNode;
356 - if (root.hydrate) {
356 + if (root.isDehydrated) {
357 // Flush the first scheduled "update".
358 const lanes = getHighestPriorityPendingLanes(root);
359 flushRoot(root, lanes);
packages/react-reconciler/src/ReactFiberReconciler.old.js
+1 -1
@@ -353,7 +353,7 @@ export function attemptSynchronousHydration(fiber: Fiber): void {
353 switch (fiber.tag) {
354 case HostRoot:
355 const root: FiberRoot = fiber.stateNode;
356 - if (root.hydrate) {
356 + if (root.isDehydrated) {
357 // Flush the first scheduled "update".
358 const lanes = getHighestPriorityPendingLanes(root);
359 flushRoot(root, lanes);
packages/react-reconciler/src/ReactFiberRoot.new.js
+1 -1
@@ -39,7 +39,7 @@ function FiberRootNode(containerInfo, tag, hydrate) {
39 this.timeoutHandle = noTimeout;
40 this.context = null;
41 this.pendingContext = null;
42 - this.hydrate = hydrate;
42 + this.isDehydrated = hydrate;
43 this.callbackNode = null;
44 this.callbackPriority = NoLane;
45 this.eventTimes = createLaneMap(NoLanes);
packages/react-reconciler/src/ReactFiberRoot.old.js
+1 -1
@@ -39,7 +39,7 @@ function FiberRootNode(containerInfo, tag, hydrate) {
39 this.timeoutHandle = noTimeout;
40 this.context = null;
41 this.pendingContext = null;
42 - this.hydrate = hydrate;
42 + this.isDehydrated = hydrate;
43 this.callbackNode = null;
44 this.callbackPriority = NoLane;
45 this.eventTimes = createLaneMap(NoLanes);
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+4 -4
@@ -859,8 +859,8 @@ function recoverFromConcurrentError(root, errorRetryLanes) {
859
860 // If an error occurred during hydration, discard server response and fall
861 // back to client side render.
862 - if (root.hydrate) {
863 - root.hydrate = false;
862 + if (root.isDehydrated) {
863 + root.isDehydrated = false;
864 if (__DEV__) {
865 errorHydratingContainer(root.containerInfo);
866 }
@@ -1076,8 +1076,8 @@ function performSyncWorkOnRoot(root) {
1076
1077 // If an error occurred during hydration,
1078 // 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;
1081 if (__DEV__) {
1082 errorHydratingContainer(root.containerInfo);
1083 }
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+4 -4
@@ -859,8 +859,8 @@ function recoverFromConcurrentError(root, errorRetryLanes) {
859
860 // If an error occurred during hydration, discard server response and fall
861 // back to client side render.
862 - if (root.hydrate) {
863 - root.hydrate = false;
862 + if (root.isDehydrated) {
863 + root.isDehydrated = false;
864 if (__DEV__) {
865 errorHydratingContainer(root.containerInfo);
866 }
@@ -1076,8 +1076,8 @@ function performSyncWorkOnRoot(root) {
1076
1077 // If an error occurred during hydration,
1078 // 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;
1081 if (__DEV__) {
1082 errorHydratingContainer(root.containerInfo);
1083 }
packages/react-reconciler/src/ReactInternalTypes.js
+1 -1
@@ -212,7 +212,7 @@ type BaseFiberRootProperties = {|
212 context: Object | null,
213 pendingContext: Object | null,
214 // Determines if we should attempt to hydrate on the initial mount
215 - +hydrate: boolean,
215 + +isDehydrated: boolean,
216
217 // Used by useMutableSource hook to avoid tearing during hydration.
218 mutableSourceEagerHydrationData?: Array<