Skip to content

Commit

Permalink
root.hydrate -> root.isDehydrated (facebook#22420)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
acdlite authored and zhengjitf committed Apr 15, 2022
1 parent 5d59624 commit aedcefb
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/ReactDOMEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/ReactDOMEventReplaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberBeginWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberBeginWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberCommitWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberReconciler.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberReconciler.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberRoot.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberRoot.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactInternalTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down

0 comments on commit aedcefb

Please sign in to comment.