Skip to content

Commit 14e4a54

Browse files
committed
[DevTools] Always attempt to mount dehydrated roots
`mountFiberRecursively` bails out of hydrating dehydrated roots nowadays. This makes the check in `handleCommitFiberRoot` redundant. Mostly doing this because the check in `handleCommitFiberRoot` wasn't mirrored in the initial mount path. `handleCommitFiberRoot` always attempted to mount dehydrated roots when it first encountered a HostRoot. But on updates, it treated a previously dehydrated HostRoot as newly mounted. This resulted in recording mounts twice which is not supported.
1 parent 223a52c commit 14e4a54

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

packages/react-devtools-shared/src/backend/fiber/renderer.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5278,14 +5278,9 @@ export function attach(
52785278
// TODO: relying on this seems a bit fishy.
52795279
const wasMounted =
52805280
prevFiber.memoizedState != null &&
5281-
prevFiber.memoizedState.element != null &&
5282-
// A dehydrated root is not considered mounted
5283-
prevFiber.memoizedState.isDehydrated !== true;
5281+
prevFiber.memoizedState.element != null;
52845282
const isMounted =
5285-
current.memoizedState != null &&
5286-
current.memoizedState.element != null &&
5287-
// A dehydrated root is not considered mounted
5288-
current.memoizedState.isDehydrated !== true;
5283+
current.memoizedState != null && current.memoizedState.element != null;
52895284
if (!wasMounted && isMounted) {
52905285
// Mount a new root.
52915286
setRootPseudoKey(currentRoot.id, current);

packages/react-devtools-shared/src/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export function printOperationsArray(operations: Array<number>) {
300300
}
301301
case TREE_OPERATION_SET_SUBTREE_MODE: {
302302
const id = operations[i + 1];
303-
const mode = operations[i + 1];
303+
const mode = operations[i + 2];
304304

305305
i += 3;
306306

@@ -339,11 +339,11 @@ export function printOperationsArray(operations: Array<number>) {
339339
const fiberID = operations[i + 1];
340340
const parentID = operations[i + 2];
341341
const nameStringID = operations[i + 3];
342-
const name = stringTable[nameStringID];
343342
const numRects = operations[i + 4];
344343

345344
i += 5;
346345

346+
const name = stringTable[nameStringID];
347347
let rects: string;
348348
if (numRects === -1) {
349349
rects = 'null';

0 commit comments

Comments
 (0)