Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/react-devtools-shared/src/backend/fiber/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6009,6 +6009,11 @@ export function attach(
nativeTag = getNativeTag(fiber.stateNode);
}

let isSuspended: boolean | null = null;
if (tag === SuspenseComponent) {
isSuspended = memoizedState !== null;
}

const suspendedBy =
fiberInstance.suspenseNode !== null
? // If this is a Suspense boundary, then we include everything in the subtree that might suspend
Expand Down Expand Up @@ -6055,6 +6060,7 @@ export function attach(
forceFallbackForFibers.has(fiber) ||
(fiber.alternate !== null &&
forceFallbackForFibers.has(fiber.alternate))),
isSuspended: isSuspended,

source,

Expand Down Expand Up @@ -6142,6 +6148,7 @@ export function attach(
const componentLogsEntry =
componentInfoToComponentLogsMap.get(componentInfo);

const isSuspended = null;
// Things that Suspended this Server Component (use(), awaits and direct child promises)
const suspendedBy = virtualInstance.suspendedBy;

Expand All @@ -6160,6 +6167,7 @@ export function attach(
isErrored: false,

canToggleSuspense: supportsTogglingSuspense && hasSuspenseBoundary,
isSuspended: isSuspended,

source,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ export function attach(

// Suspense did not exist in legacy versions
canToggleSuspense: false,
isSuspended: null,

source: null,

Expand Down
2 changes: 2 additions & 0 deletions packages/react-devtools-shared/src/backend/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ export type InspectedElement = {

// Is this Suspense, and can its value be overridden now?
canToggleSuspense: boolean,
// If this Element is suspended. Currently only set on Suspense boundaries.
isSuspended: boolean | null,

// Does the component have legacy context attached to it.
hasLegacyContext: boolean,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-devtools-shared/src/backendAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export function convertInspectedElementBackendToFrontend(
canToggleError,
isErrored,
canToggleSuspense,
isSuspended,
hasLegacyContext,
id,
type,
Expand Down Expand Up @@ -286,6 +287,7 @@ export function convertInspectedElementBackendToFrontend(
canToggleError,
isErrored,
canToggleSuspense,
isSuspended,
hasLegacyContext,
id,
key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default function InspectedElementWrapper(_: Props): React.Node {
element !== null &&
element.type === ElementTypeSuspense &&
inspectedElement != null &&
inspectedElement.state != null;
inspectedElement.isSuspended;

const canToggleError =
!hideToggleErrorAction &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ export default function InspectedElementSuspenseToggle({
}: Props): React.Node {
const {readOnly} = React.useContext(OptionsContext);

const {id, state, type} = inspectedElement;
const {id, isSuspended, type} = inspectedElement;
const canToggleSuspense = !readOnly && inspectedElement.canToggleSuspense;

if (type !== ElementTypeSuspense) {
return null;
}

const isSuspended = state !== null;

const toggleSuspense = (path: any, value: boolean) => {
const rendererID = store.getRendererIDForElement(id);
if (rendererID !== null) {
Expand Down
2 changes: 2 additions & 0 deletions packages/react-devtools-shared/src/frontend/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ export type InspectedElement = {

// Is this Suspense, and can its value be overridden now?
canToggleSuspense: boolean,
// If this Element is suspended. Currently only set on Suspense boundaries.
isSuspended: boolean | null,

// Does the component have legacy context attached to it.
hasLegacyContext: boolean,
Expand Down
Loading