@@ -4350,9 +4350,6 @@ export function attach(
4350
4350
const owners : null | Array < SerializedElement > =
4351
4351
getOwnersListFromInstance ( fiberInstance ) ;
4352
4352
4353
- const isTimedOutSuspense =
4354
- tag === SuspenseComponent && memoizedState !== null ;
4355
-
4356
4353
let hooks = null ;
4357
4354
if ( usesHooks ) {
4358
4355
const originalConsoleMethods : { [ string ] : $FlowFixMe } = { } ;
@@ -4382,14 +4379,25 @@ export function attach(
4382
4379
4383
4380
let rootType = null;
4384
4381
let current = fiber;
4382
+ let hasErrorBoundary = false;
4383
+ let hasSuspenseBoundary = false;
4385
4384
while (current.return !== null) {
4385
+ const temp = current ;
4386
4386
current = current . return ;
4387
+ if ( temp . tag === SuspenseComponent ) {
4388
+ hasSuspenseBoundary = true ;
4389
+ } else if ( isErrorBoundary ( temp ) ) {
4390
+ hasErrorBoundary = true ;
4391
+ }
4387
4392
}
4388
4393
const fiberRoot = current.stateNode;
4389
4394
if (fiberRoot != null && fiberRoot . _debugRootType !== null ) {
4390
4395
rootType = fiberRoot . _debugRootType ;
4391
4396
}
4392
4397
4398
+ const isTimedOutSuspense =
4399
+ tag === SuspenseComponent && memoizedState !== null ;
4400
+
4393
4401
let isErrored = false ;
4394
4402
if ( isErrorBoundary ( fiber ) ) {
4395
4403
// if the current inspected element is an error boundary,
@@ -4440,12 +4448,13 @@ export function attach(
4440
4448
canEditFunctionPropsRenamePaths :
4441
4449
typeof overridePropsRenamePath === 'function' ,
4442
4450
4443
- canToggleError : supportsTogglingError ,
4451
+ canToggleError : supportsTogglingError && hasErrorBoundary ,
4444
4452
// Is this error boundary in error state.
4445
4453
isErrored ,
4446
4454
4447
4455
canToggleSuspense :
4448
4456
supportsTogglingSuspense &&
4457
+ hasSuspenseBoundary &&
4449
4458
// If it's showing the real content, we can always flip fallback.
4450
4459
( ! isTimedOutSuspense ||
4451
4460
// If it's showing fallback because we previously forced it to,
@@ -4506,20 +4515,24 @@ export function attach(
4506
4515
getOwnersListFromInstance ( virtualInstance ) ;
4507
4516
4508
4517
let rootType = null ;
4509
- let parent = virtualInstance . parent ;
4510
- while ( parent !== null ) {
4511
- if ( parent . kind !== VIRTUAL_INSTANCE ) {
4512
- let current = parent . data ;
4513
- while ( current . return !== null ) {
4514
- current = current . return ;
4515
- }
4516
- const fiberRoot = current . stateNode ;
4517
- if ( fiberRoot != null && fiberRoot . _debugRootType !== null ) {
4518
- rootType = fiberRoot . _debugRootType ;
4518
+ let hasErrorBoundary = false ;
4519
+ let hasSuspenseBoundary = false ;
4520
+ const nearestFiber = getNearestFiber ( virtualInstance ) ;
4521
+ if ( nearestFiber !== null ) {
4522
+ let current = nearestFiber ;
4523
+ while ( current . return !== null ) {
4524
+ const temp = current ;
4525
+ current = current . return ;
4526
+ if ( temp . tag === SuspenseComponent ) {
4527
+ hasSuspenseBoundary = true ;
4528
+ } else if ( isErrorBoundary ( temp ) ) {
4529
+ hasErrorBoundary = true ;
4519
4530
}
4520
- break ;
4521
4531
}
4522
- parent = parent . parent ;
4532
+ const fiberRoot = current . stateNode ;
4533
+ if ( fiberRoot != null && fiberRoot . _debugRootType !== null ) {
4534
+ rootType = fiberRoot . _debugRootType ;
4535
+ }
4523
4536
}
4524
4537
4525
4538
const plugins : Plugins = {
@@ -4537,10 +4550,10 @@ export function attach(
4537
4550
canEditFunctionPropsDeletePaths : false ,
4538
4551
canEditFunctionPropsRenamePaths : false ,
4539
4552
4540
- canToggleError : supportsTogglingError ,
4553
+ canToggleError : supportsTogglingError && hasErrorBoundary ,
4541
4554
isErrored : false ,
4542
4555
4543
- canToggleSuspense : supportsTogglingSuspense ,
4556
+ canToggleSuspense : supportsTogglingSuspense && hasSuspenseBoundary ,
4544
4557
4545
4558
// Can view component source location.
4546
4559
canViewSource,
0 commit comments