Skip to content

Commit

Permalink
Null stateNode after unmount (#17666)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn authored Dec 19, 2019
1 parent 8979766 commit 1b9328c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/legacy-events/ReactControlledComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 1b9328c

Please sign in to comment.