From e576b65e2cb1a1a64a88e8defe4edbe1fdfbc001 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Sat, 27 Sep 2025 23:26:07 -0400 Subject: [PATCH 1/4] Hide props section for Suspense boundaries --- .../views/Components/InspectedElementPropsTree.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js index 729b517b46f98..dddc6e6a9de8e 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js @@ -17,7 +17,10 @@ import NewKeyValue from './NewKeyValue'; import {alphaSortEntries, serializeDataForCopy} from '../utils'; import Store from '../../store'; import styles from './InspectedElementSharedStyles.css'; -import {ElementTypeClass} from 'react-devtools-shared/src/frontend/types'; +import { + ElementTypeClass, + ElementTypeSuspense, +} from 'react-devtools-shared/src/frontend/types'; import {withPermissionsCheck} from 'react-devtools-shared/src/frontend/utils/withPermissionsCheck'; import type {InspectedElement} from 'react-devtools-shared/src/frontend/types'; @@ -47,6 +50,16 @@ export default function InspectedElementPropsTree({ type, } = inspectedElement; + if (type === ElementTypeSuspense) { + // Skip showing the props for Suspense. We want to give more real estate to the + // "Suspended by" for Suspense boundaries. We could maybe show it further below + // but in practice, the props of Suspense boundaries are not very useful to + // inspect because the name shows in the tree already. The children in the tree + // will be either the "fallback" or "children" prop which you can already inspect + // but resuspending the tree. + return null; + } + const canDeletePaths = type === ElementTypeClass || canEditFunctionPropsDeletePaths; const canEditValues = From 062c6cfbe192956038d234cedf5471ee277f0d6c Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Sat, 27 Sep 2025 23:45:37 -0400 Subject: [PATCH 2/4] Show a disabled Suspense icon while the tree is still suspended from initial mount --- .../react-devtools-shared/src/backend/fiber/renderer.js | 7 ++----- .../src/devtools/views/Components/InspectedElement.js | 9 ++++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/react-devtools-shared/src/backend/fiber/renderer.js b/packages/react-devtools-shared/src/backend/fiber/renderer.js index 222baa0dae04c..ba214db05c7dd 100644 --- a/packages/react-devtools-shared/src/backend/fiber/renderer.js +++ b/packages/react-devtools-shared/src/backend/fiber/renderer.js @@ -6596,9 +6596,6 @@ export function attach( rootType = fiberRoot._debugRootType; } - const isTimedOutSuspense = - tag === SuspenseComponent && memoizedState !== null; - let isErrored = false; if (isErrorBoundary(fiber)) { // if the current inspected element is an error boundary, @@ -6670,7 +6667,7 @@ export function attach( if ( fiberInstance.suspenseNode !== null && fiberInstance.suspenseNode.hasUnknownSuspenders && - !isTimedOutSuspense + !isSuspended ) { // Something unknown threw to suspended this boundary. Let's figure out why that might be. if (renderer.bundleType === 0) { @@ -6708,7 +6705,7 @@ export function attach( supportsTogglingSuspense && hasSuspenseBoundary && // If it's showing the real content, we can always flip fallback. - (!isTimedOutSuspense || + (!isSuspended || // If it's showing fallback because we previously forced it to, // allow toggling it back to remove the fallback override. forceFallbackForFibers.has(fiber) || diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js index 08bba4f9da41f..88aeab7bfd413 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js @@ -269,18 +269,21 @@ export default function InspectedElementWrapper(_: Props): React.Node { )} - {canToggleSuspense && ( + {canToggleSuspense || isSuspended ? ( - )} + ) : null} {store.supportsInspectMatchingDOMElement && (