From f73ae7e1aba3c7bd959aa2c4c7217075636ce695 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Mon, 22 Mar 2021 23:06:44 -0500 Subject: [PATCH] Add Flow type to new host config method --- packages/react-art/src/ReactARTHostConfig.js | 2 +- packages/react-dom/src/client/ReactDOMComponentTree.js | 7 +++---- packages/react-dom/src/client/ReactDOMHostConfig.js | 6 +----- .../react-native-renderer/src/ReactFabricHostConfig.js | 2 +- .../react-native-renderer/src/ReactNativeHostConfig.js | 2 +- packages/react-noop-renderer/src/createReactNoop.js | 2 +- packages/react-reconciler/src/ReactFiberCommitWork.new.js | 4 ++-- packages/react-reconciler/src/ReactFiberCommitWork.old.js | 4 ++-- .../src/forks/ReactFiberHostConfig.custom.js | 2 +- packages/react-test-renderer/src/ReactTestHostConfig.js | 2 +- 10 files changed, 14 insertions(+), 19 deletions(-) diff --git a/packages/react-art/src/ReactARTHostConfig.js b/packages/react-art/src/ReactARTHostConfig.js index 6a02366979a07..7ae3941c9253a 100644 --- a/packages/react-art/src/ReactARTHostConfig.js +++ b/packages/react-art/src/ReactARTHostConfig.js @@ -472,6 +472,6 @@ export function preparePortalMount(portalInstance: any): void { // noop } -export function unmountNode(node: any): void { +export function detachDeletedInstance(node: Instance): void { // noop } diff --git a/packages/react-dom/src/client/ReactDOMComponentTree.js b/packages/react-dom/src/client/ReactDOMComponentTree.js index 1c09f24931aee..2afe66035f364 100644 --- a/packages/react-dom/src/client/ReactDOMComponentTree.js +++ b/packages/react-dom/src/client/ReactDOMComponentTree.js @@ -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]; diff --git a/packages/react-dom/src/client/ReactDOMHostConfig.js b/packages/react-dom/src/client/ReactDOMHostConfig.js index 301bd2e72ef8a..b00432d045168 100644 --- a/packages/react-dom/src/client/ReactDOMHostConfig.js +++ b/packages/react-dom/src/client/ReactDOMHostConfig.js @@ -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, @@ -1210,7 +1210,3 @@ export function setupIntersectionObserver( }, }; } - -export function unmountNode(node: any): void { - unmountNodeFromDOMTree(node); -} diff --git a/packages/react-native-renderer/src/ReactFabricHostConfig.js b/packages/react-native-renderer/src/ReactFabricHostConfig.js index 121480051a4a5..52d1ecf9385e0 100644 --- a/packages/react-native-renderer/src/ReactFabricHostConfig.js +++ b/packages/react-native-renderer/src/ReactFabricHostConfig.js @@ -482,6 +482,6 @@ export function preparePortalMount(portalInstance: Instance): void { // noop } -export function unmountNode(node: any): void { +export function detachDeletedInstance(node: Instance): void { // noop } diff --git a/packages/react-native-renderer/src/ReactNativeHostConfig.js b/packages/react-native-renderer/src/ReactNativeHostConfig.js index f1ec3143020ed..84538532979e1 100644 --- a/packages/react-native-renderer/src/ReactNativeHostConfig.js +++ b/packages/react-native-renderer/src/ReactNativeHostConfig.js @@ -539,6 +539,6 @@ export function preparePortalMount(portalInstance: Instance): void { // noop } -export function unmountNode(node: any): void { +export function detachDeletedInstance(node: Instance): void { // noop } diff --git a/packages/react-noop-renderer/src/createReactNoop.js b/packages/react-noop-renderer/src/createReactNoop.js index 80b77ff9fe256..dd304fce6d878 100644 --- a/packages/react-noop-renderer/src/createReactNoop.js +++ b/packages/react-noop-renderer/src/createReactNoop.js @@ -421,7 +421,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) { throw new Error('Not yet implemented.'); }, - unmountNode() {}, + detachDeletedInstance() {}, }; const hostConfig = useMutation diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index 41900aa28aca3..3e8de112ad512 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -61,7 +61,7 @@ import { hasCaughtError, clearCaughtError, } from 'shared/ReactErrorUtils'; -import {unmountNode} from './ReactFiberHostConfig'; +import {detachDeletedInstance} from './ReactFiberHostConfig'; import { NoFlags, ContentReset, @@ -1285,7 +1285,7 @@ function detachFiberAfterEffects(fiber: Fiber) { if (fiber.tag === HostComponent) { const hostInstance: Instance = fiber.stateNode; if (hostInstance !== null) { - unmountNode(hostInstance); + detachDeletedInstance(hostInstance); } } diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.old.js b/packages/react-reconciler/src/ReactFiberCommitWork.old.js index 3acdd547adf02..67dfc947ef79a 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.old.js @@ -61,7 +61,7 @@ import { hasCaughtError, clearCaughtError, } from 'shared/ReactErrorUtils'; -import {unmountNode} from './ReactFiberHostConfig'; +import {detachDeletedInstance} from './ReactFiberHostConfig'; import { NoFlags, ContentReset, @@ -1285,7 +1285,7 @@ function detachFiberAfterEffects(fiber: Fiber) { if (fiber.tag === HostComponent) { const hostInstance: Instance = fiber.stateNode; if (hostInstance !== null) { - unmountNode(hostInstance); + detachDeletedInstance(hostInstance); } } diff --git a/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js b/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js index 8e34f5119eee9..0c2895deda989 100644 --- a/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js +++ b/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js @@ -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 diff --git a/packages/react-test-renderer/src/ReactTestHostConfig.js b/packages/react-test-renderer/src/ReactTestHostConfig.js index babb0c2437215..bac900c469fa7 100644 --- a/packages/react-test-renderer/src/ReactTestHostConfig.js +++ b/packages/react-test-renderer/src/ReactTestHostConfig.js @@ -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 }