@samitouri / QOS-React-2 / commits / 1b9328cd9b

Null stateNode after unmount (#17666)

Brian Vaughn committed Dec 19, 2019 at 13:32 UTC 1b9328cd9b516fb3d1bd125a6cbd1e9e8333ac5c
2 files changed +7 -2
packages/legacy-events/ReactControlledComponent.js
+6 -2
@@ -33,8 +33,12 @@ function restoreStateOfTarget(target) {
33 'setRestoreImplementation() needs to be called to handle a target for controlled ' +
34 'events. This error is likely caused by a bug in React. Please file an issue.',
35 );
36 - const props = getFiberCurrentPropsFromNode(internalInstance.stateNode);
37 - restoreImpl(internalInstance.stateNode, internalInstance.type, props);
36 + const stateNode = internalInstance.stateNode;
37 + // Guard against Fiber being unmounted.
38 + if (stateNode) {
39 + const props = getFiberCurrentPropsFromNode(stateNode);
40 + restoreImpl(internalInstance.stateNode, internalInstance.type, props);
41 + }
42 }
43
44 export function setRestoreImplementation(
packages/react-reconciler/src/ReactFiberCommitWork.js
+1
@@ -905,6 +905,7 @@ function detachFiber(current: Fiber) {
905 current.lastEffect = null;
906 current.pendingProps = null;
907 current.memoizedProps = null;
908 + current.stateNode = null;
909 if (alternate !== null) {
910 detachFiber(alternate);
911 }