From 1682b8dbc973c8cd3e312d4f1f92cfee8b6f49ee Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Fri, 24 Sep 2021 12:16:59 -0400 Subject: [PATCH] root.hydrate -> root.isDehydrated 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. --- packages/react-dom/src/events/ReactDOMEventListener.js | 2 +- packages/react-dom/src/events/ReactDOMEventReplaying.js | 2 +- packages/react-reconciler/src/ReactFiberBeginWork.new.js | 2 +- packages/react-reconciler/src/ReactFiberBeginWork.old.js | 2 +- packages/react-reconciler/src/ReactFiberCommitWork.new.js | 8 ++++---- packages/react-reconciler/src/ReactFiberCommitWork.old.js | 8 ++++---- .../react-reconciler/src/ReactFiberCompleteWork.new.js | 2 +- .../react-reconciler/src/ReactFiberCompleteWork.old.js | 2 +- packages/react-reconciler/src/ReactFiberReconciler.new.js | 2 +- packages/react-reconciler/src/ReactFiberReconciler.old.js | 2 +- packages/react-reconciler/src/ReactFiberRoot.new.js | 2 +- packages/react-reconciler/src/ReactFiberRoot.old.js | 2 +- packages/react-reconciler/src/ReactFiberWorkLoop.new.js | 8 ++++---- packages/react-reconciler/src/ReactFiberWorkLoop.old.js | 8 ++++---- packages/react-reconciler/src/ReactInternalTypes.js | 2 +- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/react-dom/src/events/ReactDOMEventListener.js b/packages/react-dom/src/events/ReactDOMEventListener.js index d688521726c0d..dfe3c2e3c00c0 100644 --- a/packages/react-dom/src/events/ReactDOMEventListener.js +++ b/packages/react-dom/src/events/ReactDOMEventListener.js @@ -264,7 +264,7 @@ export function attemptToDispatchEvent( targetInst = null; } else if (tag === HostRoot) { const root: FiberRoot = nearestMounted.stateNode; - if (root.hydrate) { + if (root.isDehydrated) { // If this happens during a replay something went wrong and it might block // the whole system. return getContainerFromFiber(nearestMounted); diff --git a/packages/react-dom/src/events/ReactDOMEventReplaying.js b/packages/react-dom/src/events/ReactDOMEventReplaying.js index 0587899fd8bd9..eab9b4650c108 100644 --- a/packages/react-dom/src/events/ReactDOMEventReplaying.js +++ b/packages/react-dom/src/events/ReactDOMEventReplaying.js @@ -399,7 +399,7 @@ function attemptExplicitHydrationTarget( } } else if (tag === HostRoot) { const root: FiberRoot = nearestMounted.stateNode; - if (root.hydrate) { + if (root.isDehydrated) { queuedTarget.blockedOn = getContainerFromFiber(nearestMounted); // We don't currently have a way to increase the priority of // a root other than sync. diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.new.js b/packages/react-reconciler/src/ReactFiberBeginWork.new.js index 9ad53ec00f27f..6097ec4ea1fe9 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.new.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.new.js @@ -1295,7 +1295,7 @@ function updateHostRoot(current, workInProgress, renderLanes) { resetHydrationState(); return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } - if (root.hydrate && enterHydrationState(workInProgress)) { + if (root.isDehydrated && enterHydrationState(workInProgress)) { // If we don't have any current children this might be the first pass. // We always try to hydrate. If this isn't a hydration pass there won't // be any children to hydrate which is effectively the same thing as diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.old.js b/packages/react-reconciler/src/ReactFiberBeginWork.old.js index bef7863638ff0..9779c6fb528f8 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.old.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.old.js @@ -1295,7 +1295,7 @@ function updateHostRoot(current, workInProgress, renderLanes) { resetHydrationState(); return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } - if (root.hydrate && enterHydrationState(workInProgress)) { + if (root.isDehydrated && enterHydrationState(workInProgress)) { // If we don't have any current children this might be the first pass. // We always try to hydrate. If this isn't a hydration pass there won't // be any children to hydrate which is effectively the same thing as diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index db46978eb2c69..699c6867fa103 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -1827,9 +1827,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void { case HostRoot: { if (supportsHydration) { const root: FiberRoot = finishedWork.stateNode; - if (root.hydrate) { + if (root.isDehydrated) { // We've just hydrated. No need to hydrate again. - root.hydrate = false; + root.isDehydrated = false; commitHydratedContainer(root.containerInfo); } } @@ -1933,9 +1933,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void { case HostRoot: { if (supportsHydration) { const root: FiberRoot = finishedWork.stateNode; - if (root.hydrate) { + if (root.isDehydrated) { // We've just hydrated. No need to hydrate again. - root.hydrate = false; + root.isDehydrated = false; commitHydratedContainer(root.containerInfo); } } diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.old.js b/packages/react-reconciler/src/ReactFiberCommitWork.old.js index e0131080a32fa..53294e67498b0 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.old.js @@ -1827,9 +1827,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void { case HostRoot: { if (supportsHydration) { const root: FiberRoot = finishedWork.stateNode; - if (root.hydrate) { + if (root.isDehydrated) { // We've just hydrated. No need to hydrate again. - root.hydrate = false; + root.isDehydrated = false; commitHydratedContainer(root.containerInfo); } } @@ -1933,9 +1933,9 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void { case HostRoot: { if (supportsHydration) { const root: FiberRoot = finishedWork.stateNode; - if (root.hydrate) { + if (root.isDehydrated) { // We've just hydrated. No need to hydrate again. - root.hydrate = false; + root.isDehydrated = false; commitHydratedContainer(root.containerInfo); } } diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.new.js b/packages/react-reconciler/src/ReactFiberCompleteWork.new.js index 1382439f1ee7a..03136ce30ba7b 100644 --- a/packages/react-reconciler/src/ReactFiberCompleteWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCompleteWork.new.js @@ -867,7 +867,7 @@ function completeWork( // If we hydrated, then we'll need to schedule an update for // the commit side-effects on the root. markUpdate(workInProgress); - } else if (!fiberRoot.hydrate) { + } else if (!fiberRoot.isDehydrated) { // Schedule an effect to clear this container at the start of the next commit. // This handles the case of React rendering into a container with previous children. // It's also safe to do for updates too, because current.child would only be null diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.old.js b/packages/react-reconciler/src/ReactFiberCompleteWork.old.js index 746e3d4b572da..1155a817d61b6 100644 --- a/packages/react-reconciler/src/ReactFiberCompleteWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCompleteWork.old.js @@ -867,7 +867,7 @@ function completeWork( // If we hydrated, then we'll need to schedule an update for // the commit side-effects on the root. markUpdate(workInProgress); - } else if (!fiberRoot.hydrate) { + } else if (!fiberRoot.isDehydrated) { // Schedule an effect to clear this container at the start of the next commit. // This handles the case of React rendering into a container with previous children. // It's also safe to do for updates too, because current.child would only be null diff --git a/packages/react-reconciler/src/ReactFiberReconciler.new.js b/packages/react-reconciler/src/ReactFiberReconciler.new.js index 90503a183d943..38f9955657dd0 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.new.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.new.js @@ -353,7 +353,7 @@ export function attemptSynchronousHydration(fiber: Fiber): void { switch (fiber.tag) { case HostRoot: const root: FiberRoot = fiber.stateNode; - if (root.hydrate) { + if (root.isDehydrated) { // Flush the first scheduled "update". const lanes = getHighestPriorityPendingLanes(root); flushRoot(root, lanes); diff --git a/packages/react-reconciler/src/ReactFiberReconciler.old.js b/packages/react-reconciler/src/ReactFiberReconciler.old.js index 2608bc260264f..3c0ae637529a3 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.old.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.old.js @@ -353,7 +353,7 @@ export function attemptSynchronousHydration(fiber: Fiber): void { switch (fiber.tag) { case HostRoot: const root: FiberRoot = fiber.stateNode; - if (root.hydrate) { + if (root.isDehydrated) { // Flush the first scheduled "update". const lanes = getHighestPriorityPendingLanes(root); flushRoot(root, lanes); diff --git a/packages/react-reconciler/src/ReactFiberRoot.new.js b/packages/react-reconciler/src/ReactFiberRoot.new.js index e96b12344d093..db012ad1db19d 100644 --- a/packages/react-reconciler/src/ReactFiberRoot.new.js +++ b/packages/react-reconciler/src/ReactFiberRoot.new.js @@ -39,7 +39,7 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.timeoutHandle = noTimeout; this.context = null; this.pendingContext = null; - this.hydrate = hydrate; + this.isDehydrated = hydrate; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); diff --git a/packages/react-reconciler/src/ReactFiberRoot.old.js b/packages/react-reconciler/src/ReactFiberRoot.old.js index b6e198ba2e002..03332fd545619 100644 --- a/packages/react-reconciler/src/ReactFiberRoot.old.js +++ b/packages/react-reconciler/src/ReactFiberRoot.old.js @@ -39,7 +39,7 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.timeoutHandle = noTimeout; this.context = null; this.pendingContext = null; - this.hydrate = hydrate; + this.isDehydrated = hydrate; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js index dbeb72b856326..d1a11a1b0d04e 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js @@ -859,8 +859,8 @@ function recoverFromConcurrentError(root, errorRetryLanes) { // If an error occurred during hydration, discard server response and fall // back to client side render. - if (root.hydrate) { - root.hydrate = false; + if (root.isDehydrated) { + root.isDehydrated = false; if (__DEV__) { errorHydratingContainer(root.containerInfo); } @@ -1076,8 +1076,8 @@ function performSyncWorkOnRoot(root) { // If an error occurred during hydration, // discard server response and fall back to client side render. - if (root.hydrate) { - root.hydrate = false; + if (root.isDehydrated) { + root.isDehydrated = false; if (__DEV__) { errorHydratingContainer(root.containerInfo); } diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js index af9e293d712a7..233ec1a00d9ae 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js @@ -859,8 +859,8 @@ function recoverFromConcurrentError(root, errorRetryLanes) { // If an error occurred during hydration, discard server response and fall // back to client side render. - if (root.hydrate) { - root.hydrate = false; + if (root.isDehydrated) { + root.isDehydrated = false; if (__DEV__) { errorHydratingContainer(root.containerInfo); } @@ -1076,8 +1076,8 @@ function performSyncWorkOnRoot(root) { // If an error occurred during hydration, // discard server response and fall back to client side render. - if (root.hydrate) { - root.hydrate = false; + if (root.isDehydrated) { + root.isDehydrated = false; if (__DEV__) { errorHydratingContainer(root.containerInfo); } diff --git a/packages/react-reconciler/src/ReactInternalTypes.js b/packages/react-reconciler/src/ReactInternalTypes.js index 673298b8da3de..f079b3e8f2b93 100644 --- a/packages/react-reconciler/src/ReactInternalTypes.js +++ b/packages/react-reconciler/src/ReactInternalTypes.js @@ -212,7 +212,7 @@ type BaseFiberRootProperties = {| context: Object | null, pendingContext: Object | null, // Determines if we should attempt to hydrate on the initial mount - +hydrate: boolean, + +isDehydrated: boolean, // Used by useMutableSource hook to avoid tearing during hydration. mutableSourceEagerHydrationData?: Array<