Skip to content

Commit 34b1567

Browse files
authored
[DevTools] Ignore suspense boundaries, without visual representation, in the timeline (#34824)
This ignore a Suspense boundary from the timeline when it has no visual representation. No rect. In effect, this is not blocking the user experience. Technically it could be an effect that mounts which can have a side-effect which is visible. It could also be a meta-data tag like `<title>` which is visible. We could hoistables a virtual representation by giving them a virtual rect. E.g. at the top of the page. This could be added after the fact.
1 parent b467c6e commit 34b1567

File tree

1 file changed

+13
-0
lines changed
  • packages/react-devtools-shared/src/devtools

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import type {
5151
ComponentFilter,
5252
ElementType,
5353
SuspenseNode,
54+
Rect,
5455
} from 'react-devtools-shared/src/frontend/types';
5556
import type {
5657
FrontendBridge,
@@ -99,6 +100,10 @@ export type Capabilities = {
99100
supportsAdvancedProfiling: AdvancedProfiling,
100101
};
101102

103+
function isNonZeroRect(rect: Rect) {
104+
return rect.width > 0 || rect.height > 0 || rect.x > 0 || rect.y > 0;
105+
}
106+
102107
/**
103108
* The store is the single source of truth for updates from the backend.
104109
* ContextProviders can subscribe to the Store for specific things they want to provide.
@@ -918,7 +923,15 @@ export default class Store extends EventEmitter<{
918923
if (current === undefined) {
919924
continue;
920925
}
926+
// Ignore any suspense boundaries that has no visual representation as this is not
927+
// part of the visible loading sequence.
928+
// TODO: Consider making visible meta data and other side-effects get virtual rects.
929+
const hasRects =
930+
current.rects !== null &&
931+
current.rects.length > 0 &&
932+
current.rects.some(isNonZeroRect);
921933
if (
934+
hasRects &&
922935
(!uniqueSuspendersOnly || current.hasUniqueSuspenders) &&
923936
// Roots are already included as part of the Screen
924937
current.id !== rootID

0 commit comments

Comments
 (0)