@@ -4356,9 +4356,6 @@ export function attach(
4356
4356
const owners : null | Array < SerializedElement > =
4357
4357
getOwnersListFromInstance ( fiberInstance ) ;
4358
4358
4359
- const isTimedOutSuspense =
4360
- tag === SuspenseComponent && memoizedState !== null ;
4361
-
4362
4359
let hooks = null ;
4363
4360
if ( usesHooks ) {
4364
4361
const originalConsoleMethods : { [ string ] : $FlowFixMe } = { } ;
@@ -4388,14 +4385,25 @@ export function attach(
4388
4385
4389
4386
let rootType = null;
4390
4387
let current = fiber;
4388
+ let hasErrorBoundary = false;
4389
+ let hasSuspenseBoundary = false;
4391
4390
while (current.return !== null) {
4391
+ const temp = current ;
4392
4392
current = current . return ;
4393
+ if ( temp . tag === SuspenseComponent ) {
4394
+ hasSuspenseBoundary = true ;
4395
+ } else if ( isErrorBoundary ( temp ) ) {
4396
+ hasErrorBoundary = true ;
4397
+ }
4393
4398
}
4394
4399
const fiberRoot = current.stateNode;
4395
4400
if (fiberRoot != null && fiberRoot . _debugRootType !== null ) {
4396
4401
rootType = fiberRoot . _debugRootType ;
4397
4402
}
4398
4403
4404
+ const isTimedOutSuspense =
4405
+ tag === SuspenseComponent && memoizedState !== null ;
4406
+
4399
4407
let isErrored = false ;
4400
4408
if ( isErrorBoundary ( fiber ) ) {
4401
4409
// if the current inspected element is an error boundary,
@@ -4446,12 +4454,13 @@ export function attach(
4446
4454
canEditFunctionPropsRenamePaths :
4447
4455
typeof overridePropsRenamePath === 'function' ,
4448
4456
4449
- canToggleError : supportsTogglingError ,
4457
+ canToggleError : supportsTogglingError && hasErrorBoundary ,
4450
4458
// Is this error boundary in error state.
4451
4459
isErrored ,
4452
4460
4453
4461
canToggleSuspense :
4454
4462
supportsTogglingSuspense &&
4463
+ hasSuspenseBoundary &&
4455
4464
// If it's showing the real content, we can always flip fallback.
4456
4465
( ! isTimedOutSuspense ||
4457
4466
// If it's showing fallback because we previously forced it to,
@@ -4512,20 +4521,24 @@ export function attach(
4512
4521
getOwnersListFromInstance ( virtualInstance ) ;
4513
4522
4514
4523
let rootType = null ;
4515
- let parent = virtualInstance . parent ;
4516
- while ( parent !== null ) {
4517
- if ( parent . kind !== VIRTUAL_INSTANCE ) {
4518
- let current = parent . data ;
4519
- while ( current . return !== null ) {
4520
- current = current . return ;
4521
- }
4522
- const fiberRoot = current . stateNode ;
4523
- if ( fiberRoot != null && fiberRoot . _debugRootType !== null ) {
4524
- rootType = fiberRoot . _debugRootType ;
4524
+ let hasErrorBoundary = false ;
4525
+ let hasSuspenseBoundary = false ;
4526
+ const nearestFiber = getNearestFiber ( virtualInstance ) ;
4527
+ if ( nearestFiber !== null ) {
4528
+ let current = nearestFiber ;
4529
+ while ( current . return !== null ) {
4530
+ const temp = current ;
4531
+ current = current . return ;
4532
+ if ( temp . tag === SuspenseComponent ) {
4533
+ hasSuspenseBoundary = true ;
4534
+ } else if ( isErrorBoundary ( temp ) ) {
4535
+ hasErrorBoundary = true ;
4525
4536
}
4526
- break ;
4527
4537
}
4528
- parent = parent . parent ;
4538
+ const fiberRoot = current . stateNode ;
4539
+ if ( fiberRoot != null && fiberRoot . _debugRootType !== null ) {
4540
+ rootType = fiberRoot . _debugRootType ;
4541
+ }
4529
4542
}
4530
4543
4531
4544
const plugins : Plugins = {
@@ -4543,10 +4556,10 @@ export function attach(
4543
4556
canEditFunctionPropsDeletePaths : false ,
4544
4557
canEditFunctionPropsRenamePaths : false ,
4545
4558
4546
- canToggleError : supportsTogglingError ,
4559
+ canToggleError : supportsTogglingError && hasErrorBoundary ,
4547
4560
isErrored : false ,
4548
4561
4549
- canToggleSuspense : supportsTogglingSuspense ,
4562
+ canToggleSuspense : supportsTogglingSuspense && hasSuspenseBoundary ,
4550
4563
4551
4564
// Can view component source location.
4552
4565
canViewSource,
0 commit comments