mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
[DevTools] Fix Suspense boundaries always being marked as not suspended (#34206)
This commit is contained in:
committed by
GitHub
parent
08c28aab43
commit
6b54e5e97e
@@ -6071,6 +6071,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
|
||||
@@ -6121,6 +6126,7 @@ export function attach(
|
||||
forceFallbackForFibers.has(fiber) ||
|
||||
(fiber.alternate !== null &&
|
||||
forceFallbackForFibers.has(fiber.alternate))),
|
||||
isSuspended: isSuspended,
|
||||
|
||||
source,
|
||||
|
||||
@@ -6209,6 +6215,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;
|
||||
const suspendedByRange = getSuspendedByRange(
|
||||
@@ -6230,6 +6237,7 @@ export function attach(
|
||||
isErrored: false,
|
||||
|
||||
canToggleSuspense: supportsTogglingSuspense && hasSuspenseBoundary,
|
||||
isSuspended: isSuspended,
|
||||
|
||||
source,
|
||||
|
||||
|
||||
@@ -836,6 +836,7 @@ export function attach(
|
||||
|
||||
// Suspense did not exist in legacy versions
|
||||
canToggleSuspense: false,
|
||||
isSuspended: null,
|
||||
|
||||
source: null,
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -251,6 +251,7 @@ export function convertInspectedElementBackendToFrontend(
|
||||
canToggleError,
|
||||
isErrored,
|
||||
canToggleSuspense,
|
||||
isSuspended,
|
||||
hasLegacyContext,
|
||||
id,
|
||||
type,
|
||||
@@ -287,6 +288,7 @@ export function convertInspectedElementBackendToFrontend(
|
||||
canToggleError,
|
||||
isErrored,
|
||||
canToggleSuspense,
|
||||
isSuspended,
|
||||
hasLegacyContext,
|
||||
id,
|
||||
key,
|
||||
|
||||
+1
-1
@@ -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 &&
|
||||
|
||||
Vendored
+1
-3
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user