Skip to content

Commit

Permalink
Clear fiber field from host instance on unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Apr 21, 2020
1 parent ff431b7 commit f2940a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/react-dom/src/client/ReactDOMComponentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export function precacheFiberNode(
(node: any)[internalInstanceKey] = hostInst;
}

export function clearFiberNode(
node: Instance | TextInstance | SuspenseInstance,
): void {
(node: any)[internalInstanceKey] = null;
}

export function markContainerAsRoot(hostRoot: Fiber, node: Container): void {
node[internalContainerInstanceKey] = hostRoot;
}
Expand Down
7 changes: 5 additions & 2 deletions packages/react-dom/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
precacheFiberNode,
updateFiberProps,
getClosestInstanceFromNode,
clearFiberNode,
} from './ReactDOMComponentTree';
import {
createElement,
Expand Down Expand Up @@ -522,8 +523,10 @@ function dispatchAfterDetachedBlur(target: HTMLElement): void {

export function beforeRemoveInstance(
instance: Instance | TextInstance | SuspenseInstance,
) {
// TODO for ReactDOM.createEventInstance
): void {
// Clear the fiber off the instance, to help GC
clearFiberNode(instance);
// TODO handle ReactDOM.createEventInstance
}

export function removeChild(
Expand Down

0 comments on commit f2940a8

Please sign in to comment.