Skip to content

Commit 92fc74f

Browse files
committed
[DevTools] Measure when reconnecting Suspense
1 parent dd2acf4 commit 92fc74f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/react-devtools-shared/src/__tests__/store-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3391,7 +3391,7 @@ describe('Store', () => {
33913391
<Component key="inner-content">
33923392
[suspense-root] rects={[{x:1,y:2,width:15,height:1}, {x:1,y:2,width:14,height:1}]}
33933393
<Suspense name="outer" rects={[{x:1,y:2,width:15,height:1}, {x:1,y:2,width:14,height:1}]}>
3394-
<Suspense name="inner" rects={[{x:1,y:2,width:13,height:1}]}>
3394+
<Suspense name="inner" rects={[{x:1,y:2,width:14,height:1}]}>
33953395
`);
33963396
});
33973397
});

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,6 +2551,17 @@ export function attach(
25512551
25522552
const isRoot = fiber.tag === HostRoot;
25532553
2554+
const suspenseNode = fiberInstance.suspenseNode;
2555+
if (suspenseNode !== null && fiber.memoizedState === null) {
2556+
// We're reconnecting an unsuspended Suspense. Measure to see if anything changed.
2557+
const prevRects = suspenseNode.rects;
2558+
const nextRects = measureInstance(fiberInstance);
2559+
if (!areEqualRects(prevRects, nextRects)) {
2560+
suspenseNode.rects = nextRects;
2561+
recordSuspenseResize(suspenseNode);
2562+
}
2563+
}
2564+
25542565
if (isRoot) {
25552566
const hasOwnerMetadata = fiber.hasOwnProperty('_debugOwner');
25562567

0 commit comments

Comments
 (0)