diff --git a/packages/legacy-events/ReactControlledComponent.js b/packages/legacy-events/ReactControlledComponent.js index b988a326bc317..830f2a1b1cf4c 100644 --- a/packages/legacy-events/ReactControlledComponent.js +++ b/packages/legacy-events/ReactControlledComponent.js @@ -33,8 +33,12 @@ function restoreStateOfTarget(target) { 'setRestoreImplementation() needs to be called to handle a target for controlled ' + 'events. This error is likely caused by a bug in React. Please file an issue.', ); - const props = getFiberCurrentPropsFromNode(internalInstance.stateNode); - restoreImpl(internalInstance.stateNode, internalInstance.type, props); + const stateNode = internalInstance.stateNode; + // Guard against Fiber being unmounted. + if (stateNode) { + const props = getFiberCurrentPropsFromNode(stateNode); + restoreImpl(internalInstance.stateNode, internalInstance.type, props); + } } export function setRestoreImplementation( diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index c4c3fed4e86b9..a5bd4cf3cc1b5 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -905,6 +905,7 @@ function detachFiber(current: Fiber) { current.lastEffect = null; current.pendingProps = null; current.memoizedProps = null; + current.stateNode = null; if (alternate !== null) { detachFiber(alternate); }