Skip to content

Commit 443bbe0

Browse files
committed
[DevTools] Fix a crash when rendering a new class Component when simulating errored state
1 parent 88f2f39 commit 443bbe0

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

packages/react-devtools-shared/src/backend/fiber/renderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7898,7 +7898,7 @@ export function attach(
78987898
// Map of Fiber and its force error status: true (error), false (toggled off)
78997899
const forceErrorForFibers = new Map<Fiber, boolean>();
79007900
7901-
function shouldErrorFiberAccordingToMap(fiber: any): boolean {
7901+
function shouldErrorFiberAccordingToMap(fiber: any): boolean | null {
79027902
if (typeof setErrorHandler !== 'function') {
79037903
throw new Error(
79047904
'Expected overrideError() to not get called for earlier React versions.',
@@ -7934,7 +7934,7 @@ export function attach(
79347934
}
79357935
}
79367936
if (status === undefined) {
7937-
return false;
7937+
return null;
79387938
}
79397939
return status;
79407940
}

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,9 @@ function updateClassComponent(
15841584
// This is used by DevTools to force a boundary to error.
15851585
switch (shouldError(workInProgress)) {
15861586
case false: {
1587+
// We previously simulated an error on this boundary
1588+
// so the instance must have been constructed in a previous
1589+
// commit.
15871590
const instance = workInProgress.stateNode;
15881591
const ctor = workInProgress.type;
15891592
// TODO This way of resetting the error boundary state is a hack.

0 commit comments

Comments
 (0)