Skip to content

Commit

Permalink
Add Flow type to new host config method
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed Mar 23, 2021
1 parent 100239e commit f73ae7e
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/react-art/src/ReactARTHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,6 @@ export function preparePortalMount(portalInstance: any): void {
// noop
}

export function unmountNode(node: any): void {
export function detachDeletedInstance(node: Instance): void {
// noop
}
7 changes: 3 additions & 4 deletions packages/react-dom/src/client/ReactDOMComponentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ const internalEventHandlersKey = '__reactEvents$' + randomKey;
const internalEventHandlerListenersKey = '__reactListeners$' + randomKey;
const internalEventHandlesSetKey = '__reactHandles$' + randomKey;

export function unmountNode(
node: Instance | TextInstance | SuspenseInstance | ReactScopeInstance,
): void {
export function detachDeletedInstance(node: Instance): void {
// TODO: This function is only called on host components. I don't think all of
// these fields are relevant.
delete (node: any)[internalInstanceKey];
delete (node: any)[internalPropsKey];
delete (node: any)[internalContainerInstanceKey];
delete (node: any)[internalEventHandlersKey];
delete (node: any)[internalEventHandlerListenersKey];
delete (node: any)[internalEventHandlesSetKey];
Expand Down
6 changes: 1 addition & 5 deletions packages/react-dom/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import {
getFiberFromScopeInstance,
getInstanceFromNode as getInstanceFromNodeDOMTree,
isContainerMarkedAsRoot,
unmountNode as unmountNodeFromDOMTree,
} from './ReactDOMComponentTree';
export {detachDeletedInstance} from './ReactDOMComponentTree';
import {hasRole} from './DOMAccessibilityRoles';
import {
createElement,
Expand Down Expand Up @@ -1210,7 +1210,3 @@ export function setupIntersectionObserver(
},
};
}

export function unmountNode(node: any): void {
unmountNodeFromDOMTree(node);
}
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,6 @@ export function preparePortalMount(portalInstance: Instance): void {
// noop
}

export function unmountNode(node: any): void {
export function detachDeletedInstance(node: Instance): void {
// noop
}
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,6 @@ export function preparePortalMount(portalInstance: Instance): void {
// noop
}

export function unmountNode(node: any): void {
export function detachDeletedInstance(node: Instance): void {
// noop
}
2 changes: 1 addition & 1 deletion packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
throw new Error('Not yet implemented.');
},

unmountNode() {},
detachDeletedInstance() {},
};

const hostConfig = useMutation
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberCommitWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import {
hasCaughtError,
clearCaughtError,
} from 'shared/ReactErrorUtils';
import {unmountNode} from './ReactFiberHostConfig';
import {detachDeletedInstance} from './ReactFiberHostConfig';
import {
NoFlags,
ContentReset,
Expand Down Expand Up @@ -1285,7 +1285,7 @@ function detachFiberAfterEffects(fiber: Fiber) {
if (fiber.tag === HostComponent) {
const hostInstance: Instance = fiber.stateNode;
if (hostInstance !== null) {
unmountNode(hostInstance);
detachDeletedInstance(hostInstance);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import {
hasCaughtError,
clearCaughtError,
} from 'shared/ReactErrorUtils';
import {unmountNode} from './ReactFiberHostConfig';
import {detachDeletedInstance} from './ReactFiberHostConfig';
import {
NoFlags,
ContentReset,
Expand Down Expand Up @@ -1285,7 +1285,7 @@ function detachFiberAfterEffects(fiber: Fiber) {
if (fiber.tag === HostComponent) {
const hostInstance: Instance = fiber.stateNode;
if (hostInstance !== null) {
unmountNode(hostInstance);
detachDeletedInstance(hostInstance);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const preparePortalMount = $$$hostConfig.preparePortalMount;
export const prepareScopeUpdate = $$$hostConfig.preparePortalMount;
export const getInstanceFromScope = $$$hostConfig.getInstanceFromScope;
export const getCurrentEventPriority = $$$hostConfig.getCurrentEventPriority;
export const unmountNode = $$$hostConfig.unmountNode;
export const detachDeletedInstance = $$$hostConfig.detachDeletedInstance;

// -------------------
// Microtasks
Expand Down
2 changes: 1 addition & 1 deletion packages/react-test-renderer/src/ReactTestHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,6 @@ export function getInstanceFromScope(scopeInstance: Object): null | Object {
return nodeToInstanceMap.get(scopeInstance) || null;
}

export function unmountNode(node: any): void {
export function detachDeletedInstance(node: Instance): void {
// noop
}

0 comments on commit f73ae7e

Please sign in to comment.