mirror of
https://github.com/facebook/react.git
synced 2026-02-26 17:35:05 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<
|
||||
|
||||
Reference in New Issue
Block a user