From 4ecf11977c46966d3deedcdc71f1280a34607d1d Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 5 Feb 2021 20:36:55 +0000 Subject: [PATCH] Remove the Fundamental internals (#20745) --- packages/react-art/src/ReactARTHostConfig.js | 20 -- .../src/backend/ReactSymbols.js | 3 - .../src/client/ReactDOMHostConfig.js | 64 ----- .../src/server/ReactPartialRenderer.js | 39 --- .../react-dom/src/shared/ReactDOMTypes.js | 10 +- .../src/ReactFabricHostConfig.js | 24 -- .../src/ReactNativeHostConfig.js | 20 -- .../src/createReactNoop.js | 51 ---- .../react-reconciler/src/ReactFiber.new.js | 35 +-- .../react-reconciler/src/ReactFiber.old.js | 35 +-- .../src/ReactFiberBeginWork.new.js | 20 -- .../src/ReactFiberBeginWork.old.js | 20 -- .../src/ReactFiberCommitWork.new.js | 61 +---- .../src/ReactFiberCommitWork.old.js | 61 +---- .../src/ReactFiberCompleteWork.new.js | 86 +------ .../src/ReactFiberCompleteWork.old.js | 86 +------ .../src/ReactFiberFundamental.new.js | 30 --- .../src/ReactFiberFundamental.old.js | 30 --- .../ReactFiberHostConfigWithNoPersistence.js | 1 - .../src/ReactFiberReconciler.new.js | 4 - .../src/ReactFiberReconciler.old.js | 4 - .../src/ReactFiberTreeReflection.js | 8 +- .../react-reconciler/src/ReactWorkTags.js | 1 - .../ReactFiberFundamental-test.internal.js | 231 ------------------ .../src/forks/ReactFiberHostConfig.custom.js | 11 - .../src/ReactTestHostConfig.js | 50 ---- packages/react/index.js | 1 - packages/react/src/React.js | 3 - packages/react/src/ReactFundamental.js | 33 --- packages/shared/ReactFeatureFlags.js | 3 - packages/shared/ReactSymbols.js | 2 - packages/shared/ReactTypes.js | 46 ---- .../forks/ReactFeatureFlags.native-fb.js | 1 - .../forks/ReactFeatureFlags.native-oss.js | 1 - .../forks/ReactFeatureFlags.test-renderer.js | 1 - .../ReactFeatureFlags.test-renderer.native.js | 1 - .../ReactFeatureFlags.test-renderer.www.js | 1 - .../shared/forks/ReactFeatureFlags.testing.js | 1 - .../forks/ReactFeatureFlags.testing.www.js | 1 - .../shared/forks/ReactFeatureFlags.www.js | 2 - packages/shared/isValidElementType.js | 2 - 41 files changed, 12 insertions(+), 1092 deletions(-) delete mode 100644 packages/react-reconciler/src/ReactFiberFundamental.new.js delete mode 100644 packages/react-reconciler/src/ReactFiberFundamental.old.js delete mode 100644 packages/react-reconciler/src/__tests__/ReactFiberFundamental-test.internal.js delete mode 100644 packages/react/src/ReactFundamental.js diff --git a/packages/react-art/src/ReactARTHostConfig.js b/packages/react-art/src/ReactARTHostConfig.js index d31b611ddb34c..80b4a39f396bf 100644 --- a/packages/react-art/src/ReactARTHostConfig.js +++ b/packages/react-art/src/ReactARTHostConfig.js @@ -428,26 +428,6 @@ export function clearContainer(container) { // TODO Implement this } -export function getFundamentalComponentInstance(fundamentalInstance) { - throw new Error('Not yet implemented.'); -} - -export function mountFundamentalComponent(fundamentalInstance) { - throw new Error('Not yet implemented.'); -} - -export function shouldUpdateFundamentalComponent(fundamentalInstance) { - throw new Error('Not yet implemented.'); -} - -export function updateFundamentalComponent(fundamentalInstance) { - throw new Error('Not yet implemented.'); -} - -export function unmountFundamentalComponent(fundamentalInstance) { - throw new Error('Not yet implemented.'); -} - export function getInstanceFromNode(node) { throw new Error('Not yet implemented.'); } diff --git a/packages/react-devtools-shared/src/backend/ReactSymbols.js b/packages/react-devtools-shared/src/backend/ReactSymbols.js index 88e2ec29416d4..c6515f02edc51 100644 --- a/packages/react-devtools-shared/src/backend/ReactSymbols.js +++ b/packages/react-devtools-shared/src/backend/ReactSymbols.js @@ -34,9 +34,6 @@ export const FORWARD_REF_SYMBOL_STRING = 'Symbol(react.forward_ref)'; export const FRAGMENT_NUMBER = 0xeacb; export const FRAGMENT_SYMBOL_STRING = 'Symbol(react.fragment)'; -export const FUNDAMENTAL_NUMBER = 0xead5; -export const FUNDAMENTAL_SYMBOL_STRING = 'Symbol(react.fundamental)'; - export const LAZY_NUMBER = 0xead4; export const LAZY_SYMBOL_STRING = 'Symbol(react.lazy)'; diff --git a/packages/react-dom/src/client/ReactDOMHostConfig.js b/packages/react-dom/src/client/ReactDOMHostConfig.js index 561ebc4476e36..9576b602fcc98 100644 --- a/packages/react-dom/src/client/ReactDOMHostConfig.js +++ b/packages/react-dom/src/client/ReactDOMHostConfig.js @@ -16,7 +16,6 @@ import type { } from 'react-reconciler/src/ReactTestSelectors'; import type {RootType} from './ReactDOMRoot'; import type {ReactScopeInstance} from 'shared/ReactTypes'; -import type {ReactDOMFundamentalComponentInstance} from '../shared/ReactDOMTypes'; import { precacheFiberNode, @@ -64,7 +63,6 @@ import {retryIfBlockedOn} from '../events/ReactDOMEventReplaying'; import { enableSuspenseServerRenderer, - enableFundamentalAPI, enableCreateEventHandleAPI, enableScopeAPI, } from 'shared/ReactFeatureFlags'; @@ -988,68 +986,6 @@ export function didNotFindHydratableSuspenseInstance( } } -export function getFundamentalComponentInstance( - fundamentalInstance: ReactDOMFundamentalComponentInstance, -): Instance { - if (enableFundamentalAPI) { - const {currentFiber, impl, props, state} = fundamentalInstance; - const instance = impl.getInstance(null, props, state); - precacheFiberNode(currentFiber, instance); - return instance; - } - // Because of the flag above, this gets around the Flow error; - return (null: any); -} - -export function mountFundamentalComponent( - fundamentalInstance: ReactDOMFundamentalComponentInstance, -): void { - if (enableFundamentalAPI) { - const {impl, instance, props, state} = fundamentalInstance; - const onMount = impl.onMount; - if (onMount !== undefined) { - onMount(null, instance, props, state); - } - } -} - -export function shouldUpdateFundamentalComponent( - fundamentalInstance: ReactDOMFundamentalComponentInstance, -): boolean { - if (enableFundamentalAPI) { - const {impl, prevProps, props, state} = fundamentalInstance; - const shouldUpdate = impl.shouldUpdate; - if (shouldUpdate !== undefined) { - return shouldUpdate(null, prevProps, props, state); - } - } - return true; -} - -export function updateFundamentalComponent( - fundamentalInstance: ReactDOMFundamentalComponentInstance, -): void { - if (enableFundamentalAPI) { - const {impl, instance, prevProps, props, state} = fundamentalInstance; - const onUpdate = impl.onUpdate; - if (onUpdate !== undefined) { - onUpdate(null, instance, prevProps, props, state); - } - } -} - -export function unmountFundamentalComponent( - fundamentalInstance: ReactDOMFundamentalComponentInstance, -): void { - if (enableFundamentalAPI) { - const {impl, instance, props, state} = fundamentalInstance; - const onUnmount = impl.onUnmount; - if (onUnmount !== undefined) { - onUnmount(null, instance, props, state); - } - } -} - export function getInstanceFromNode(node: HTMLElement): null | Object { return getClosestInstanceFromNode(node) || null; } diff --git a/packages/react-dom/src/server/ReactPartialRenderer.js b/packages/react-dom/src/server/ReactPartialRenderer.js index 3ef3137871661..a8528ed946dc5 100644 --- a/packages/react-dom/src/server/ReactPartialRenderer.js +++ b/packages/react-dom/src/server/ReactPartialRenderer.js @@ -22,7 +22,6 @@ import { disableLegacyContext, disableModulePatternComponents, enableSuspenseServerRenderer, - enableFundamentalAPI, enableScopeAPI, } from 'shared/ReactFeatureFlags'; @@ -39,7 +38,6 @@ import { REACT_CONTEXT_TYPE, REACT_LAZY_TYPE, REACT_MEMO_TYPE, - REACT_FUNDAMENTAL_TYPE, REACT_SCOPE_TYPE, REACT_LEGACY_HIDDEN_TYPE, } from 'shared/ReactSymbols'; @@ -1253,43 +1251,6 @@ class ReactDOMServerRenderer { return ''; } // eslint-disable-next-line-no-fallthrough - case REACT_FUNDAMENTAL_TYPE: { - if (enableFundamentalAPI) { - const fundamentalImpl = elementType.impl; - const open = fundamentalImpl.getServerSideString( - null, - nextElement.props, - ); - const getServerSideStringClose = - fundamentalImpl.getServerSideStringClose; - const close = - getServerSideStringClose !== undefined - ? getServerSideStringClose(null, nextElement.props) - : ''; - const nextChildren = - fundamentalImpl.reconcileChildren !== false - ? toArray(((nextChild: any): ReactElement).props.children) - : []; - const frame: Frame = { - type: null, - domNamespace: parentNamespace, - children: nextChildren, - childIndex: 0, - context: context, - footer: close, - }; - if (__DEV__) { - ((frame: any): FrameDev).debugElementStack = []; - } - this.stack.push(frame); - return open; - } - invariant( - false, - 'ReactDOMServer does not yet support the fundamental API.', - ); - } - // eslint-disable-next-line-no-fallthrough case REACT_LAZY_TYPE: { const element: ReactElement = (nextChild: any); const lazyComponent: LazyComponent = (nextChild: any) diff --git a/packages/react-dom/src/shared/ReactDOMTypes.js b/packages/react-dom/src/shared/ReactDOMTypes.js index 774e776b1ad84..4e2eddb9a0d75 100644 --- a/packages/react-dom/src/shared/ReactDOMTypes.js +++ b/packages/react-dom/src/shared/ReactDOMTypes.js @@ -7,17 +7,9 @@ * @flow */ -import type { - ReactFundamentalComponentInstance, - ReactScopeInstance, -} from 'shared/ReactTypes'; +import type {ReactScopeInstance} from 'shared/ReactTypes'; import type {DOMEventName} from '../events/DOMEventNames'; -export type ReactDOMFundamentalComponentInstance = ReactFundamentalComponentInstance< - any, - any, ->; - export type ReactDOMEventHandle = ( target: EventTarget | ReactScopeInstance, callback: (SyntheticEvent) => void, diff --git a/packages/react-native-renderer/src/ReactFabricHostConfig.js b/packages/react-native-renderer/src/ReactFabricHostConfig.js index b8e18a01ebcee..912f33633380b 100644 --- a/packages/react-native-renderer/src/ReactFabricHostConfig.js +++ b/packages/react-native-renderer/src/ReactFabricHostConfig.js @@ -438,30 +438,6 @@ export function replaceContainerChildren( newChildren: ChildSet, ): void {} -export function getFundamentalComponentInstance(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - -export function mountFundamentalComponent(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - -export function shouldUpdateFundamentalComponent(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - -export function updateFundamentalComponent(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - -export function unmountFundamentalComponent(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - -export function cloneFundamentalInstance(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - export function getInstanceFromNode(node: any) { throw new Error('Not yet implemented.'); } diff --git a/packages/react-native-renderer/src/ReactNativeHostConfig.js b/packages/react-native-renderer/src/ReactNativeHostConfig.js index 8331979199e75..86217bdc4d03d 100644 --- a/packages/react-native-renderer/src/ReactNativeHostConfig.js +++ b/packages/react-native-renderer/src/ReactNativeHostConfig.js @@ -495,26 +495,6 @@ export function unhideTextInstance( throw new Error('Not yet implemented.'); } -export function getFundamentalComponentInstance(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - -export function mountFundamentalComponent(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - -export function shouldUpdateFundamentalComponent(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - -export function updateFundamentalComponent(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - -export function unmountFundamentalComponent(fundamentalInstance: any) { - throw new Error('Not yet implemented.'); -} - export function getInstanceFromNode(node: any) { throw new Error('Not yet implemented.'); } diff --git a/packages/react-noop-renderer/src/createReactNoop.js b/packages/react-noop-renderer/src/createReactNoop.js index fab721c7bca29..5a71567ab62f1 100644 --- a/packages/react-noop-renderer/src/createReactNoop.js +++ b/packages/react-noop-renderer/src/createReactNoop.js @@ -397,57 +397,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) { warnsIfNotActing: true, supportsHydration: false, - getFundamentalComponentInstance(fundamentalInstance): Instance { - const {impl, props, state} = fundamentalInstance; - return impl.getInstance(null, props, state); - }, - - mountFundamentalComponent(fundamentalInstance): void { - const {impl, instance, props, state} = fundamentalInstance; - const onMount = impl.onUpdate; - if (onMount !== undefined) { - onMount(null, instance, props, state); - } - }, - - shouldUpdateFundamentalComponent(fundamentalInstance): boolean { - const {impl, instance, prevProps, props, state} = fundamentalInstance; - const shouldUpdate = impl.shouldUpdate; - if (shouldUpdate !== undefined) { - return shouldUpdate(null, instance, prevProps, props, state); - } - return true; - }, - - updateFundamentalComponent(fundamentalInstance): void { - const {impl, instance, prevProps, props, state} = fundamentalInstance; - const onUpdate = impl.onUpdate; - if (onUpdate !== undefined) { - onUpdate(null, instance, prevProps, props, state); - } - }, - - unmountFundamentalComponent(fundamentalInstance): void { - const {impl, instance, props, state} = fundamentalInstance; - const onUnmount = impl.onUnmount; - if (onUnmount !== undefined) { - onUnmount(null, instance, props, state); - } - }, - - cloneFundamentalInstance(fundamentalInstance): Instance { - const instance = fundamentalInstance.instance; - return { - children: [], - text: instance.text, - type: instance.type, - prop: instance.prop, - id: instance.id, - context: instance.context, - hidden: instance.hidden, - }; - }, - getInstanceFromNode() { throw new Error('Not yet implemented.'); }, diff --git a/packages/react-reconciler/src/ReactFiber.new.js b/packages/react-reconciler/src/ReactFiber.new.js index d6c28749f26da..983855ced5685 100644 --- a/packages/react-reconciler/src/ReactFiber.new.js +++ b/packages/react-reconciler/src/ReactFiber.new.js @@ -8,12 +8,7 @@ */ import type {ReactElement} from 'shared/ReactElementType'; -import type { - ReactFragment, - ReactPortal, - ReactFundamentalComponent, - ReactScope, -} from 'shared/ReactTypes'; +import type {ReactFragment, ReactPortal, ReactScope} from 'shared/ReactTypes'; import type {Fiber} from './ReactInternalTypes'; import type {RootTag} from './ReactRootTags'; import type {WorkTag} from './ReactWorkTags'; @@ -25,7 +20,6 @@ import type {OffscreenProps} from './ReactFiberOffscreenComponent'; import invariant from 'shared/invariant'; import { enableProfilerTimer, - enableFundamentalAPI, enableScopeAPI, enableCache, } from 'shared/ReactFeatureFlags'; @@ -51,7 +45,6 @@ import { MemoComponent, SimpleMemoComponent, LazyComponent, - FundamentalComponent, ScopeComponent, OffscreenComponent, LegacyHiddenComponent, @@ -86,7 +79,6 @@ import { REACT_SUSPENSE_LIST_TYPE, REACT_MEMO_TYPE, REACT_LAZY_TYPE, - REACT_FUNDAMENTAL_TYPE, REACT_SCOPE_TYPE, REACT_OFFSCREEN_TYPE, REACT_LEGACY_HIDDEN_TYPE, @@ -525,17 +517,6 @@ export function createFiberFromTypeAndProps( fiberTag = LazyComponent; resolvedType = null; break getTag; - case REACT_FUNDAMENTAL_TYPE: - if (enableFundamentalAPI) { - return createFiberFromFundamental( - type, - pendingProps, - mode, - lanes, - key, - ); - } - break; } } let info = ''; @@ -618,20 +599,6 @@ export function createFiberFromFragment( return fiber; } -export function createFiberFromFundamental( - fundamentalComponent: ReactFundamentalComponent, - pendingProps: any, - mode: TypeOfMode, - lanes: Lanes, - key: null | string, -): Fiber { - const fiber = createFiber(FundamentalComponent, pendingProps, key, mode); - fiber.elementType = fundamentalComponent; - fiber.type = fundamentalComponent; - fiber.lanes = lanes; - return fiber; -} - function createFiberFromScope( scope: ReactScope, pendingProps: any, diff --git a/packages/react-reconciler/src/ReactFiber.old.js b/packages/react-reconciler/src/ReactFiber.old.js index c9783c3b7137f..ed2ae45f4ec17 100644 --- a/packages/react-reconciler/src/ReactFiber.old.js +++ b/packages/react-reconciler/src/ReactFiber.old.js @@ -8,12 +8,7 @@ */ import type {ReactElement} from 'shared/ReactElementType'; -import type { - ReactFragment, - ReactPortal, - ReactFundamentalComponent, - ReactScope, -} from 'shared/ReactTypes'; +import type {ReactFragment, ReactPortal, ReactScope} from 'shared/ReactTypes'; import type {Fiber} from './ReactInternalTypes'; import type {RootTag} from './ReactRootTags'; import type {WorkTag} from './ReactWorkTags'; @@ -25,7 +20,6 @@ import type {OffscreenProps} from './ReactFiberOffscreenComponent'; import invariant from 'shared/invariant'; import { enableProfilerTimer, - enableFundamentalAPI, enableScopeAPI, enableCache, } from 'shared/ReactFeatureFlags'; @@ -51,7 +45,6 @@ import { MemoComponent, SimpleMemoComponent, LazyComponent, - FundamentalComponent, ScopeComponent, OffscreenComponent, LegacyHiddenComponent, @@ -86,7 +79,6 @@ import { REACT_SUSPENSE_LIST_TYPE, REACT_MEMO_TYPE, REACT_LAZY_TYPE, - REACT_FUNDAMENTAL_TYPE, REACT_SCOPE_TYPE, REACT_OFFSCREEN_TYPE, REACT_LEGACY_HIDDEN_TYPE, @@ -525,17 +517,6 @@ export function createFiberFromTypeAndProps( fiberTag = LazyComponent; resolvedType = null; break getTag; - case REACT_FUNDAMENTAL_TYPE: - if (enableFundamentalAPI) { - return createFiberFromFundamental( - type, - pendingProps, - mode, - lanes, - key, - ); - } - break; } } let info = ''; @@ -618,20 +599,6 @@ export function createFiberFromFragment( return fiber; } -export function createFiberFromFundamental( - fundamentalComponent: ReactFundamentalComponent, - pendingProps: any, - mode: TypeOfMode, - lanes: Lanes, - key: null | string, -): Fiber { - const fiber = createFiber(FundamentalComponent, pendingProps, key, mode); - fiber.elementType = fundamentalComponent; - fiber.type = fundamentalComponent; - fiber.lanes = lanes; - return fiber; -} - function createFiberFromScope( scope: ReactScope, pendingProps: any, diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.new.js b/packages/react-reconciler/src/ReactFiberBeginWork.new.js index 2239906d43e4b..6537d103e2324 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.new.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.new.js @@ -52,7 +52,6 @@ import { SimpleMemoComponent, LazyComponent, IncompleteClassComponent, - FundamentalComponent, ScopeComponent, OffscreenComponent, LegacyHiddenComponent, @@ -79,7 +78,6 @@ import { enableProfilerTimer, enableSchedulerTracing, enableSuspenseServerRenderer, - enableFundamentalAPI, warnAboutDefaultPropsOnFunctionComponents, enableScopeAPI, enableCache, @@ -3063,18 +3061,6 @@ function updateContextConsumer( return workInProgress.child; } -function updateFundamentalComponent(current, workInProgress, renderLanes) { - const fundamentalImpl = workInProgress.type.impl; - if (fundamentalImpl.reconcileChildren === false) { - return null; - } - const nextProps = workInProgress.pendingProps; - const nextChildren = nextProps.children; - - reconcileChildren(current, workInProgress, nextChildren, renderLanes); - return workInProgress.child; -} - function updateScopeComponent(current, workInProgress, renderLanes) { const nextProps = workInProgress.pendingProps; const nextChildren = nextProps.children; @@ -3571,12 +3557,6 @@ function beginWork( case SuspenseListComponent: { return updateSuspenseListComponent(current, workInProgress, renderLanes); } - case FundamentalComponent: { - if (enableFundamentalAPI) { - return updateFundamentalComponent(current, workInProgress, renderLanes); - } - break; - } case ScopeComponent: { if (enableScopeAPI) { return updateScopeComponent(current, workInProgress, renderLanes); diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.old.js b/packages/react-reconciler/src/ReactFiberBeginWork.old.js index 5f9ba706b4229..4c0594329d94e 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.old.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.old.js @@ -52,7 +52,6 @@ import { SimpleMemoComponent, LazyComponent, IncompleteClassComponent, - FundamentalComponent, ScopeComponent, OffscreenComponent, LegacyHiddenComponent, @@ -79,7 +78,6 @@ import { enableProfilerTimer, enableSchedulerTracing, enableSuspenseServerRenderer, - enableFundamentalAPI, warnAboutDefaultPropsOnFunctionComponents, enableScopeAPI, enableCache, @@ -3063,18 +3061,6 @@ function updateContextConsumer( return workInProgress.child; } -function updateFundamentalComponent(current, workInProgress, renderLanes) { - const fundamentalImpl = workInProgress.type.impl; - if (fundamentalImpl.reconcileChildren === false) { - return null; - } - const nextProps = workInProgress.pendingProps; - const nextChildren = nextProps.children; - - reconcileChildren(current, workInProgress, nextChildren, renderLanes); - return workInProgress.child; -} - function updateScopeComponent(current, workInProgress, renderLanes) { const nextProps = workInProgress.pendingProps; const nextChildren = nextProps.children; @@ -3571,12 +3557,6 @@ function beginWork( case SuspenseListComponent: { return updateSuspenseListComponent(current, workInProgress, renderLanes); } - case FundamentalComponent: { - if (enableFundamentalAPI) { - return updateFundamentalComponent(current, workInProgress, renderLanes); - } - break; - } case ScopeComponent: { if (enableScopeAPI) { return updateScopeComponent(current, workInProgress, renderLanes); diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index 29fbd87720128..e170114848cc8 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -33,7 +33,6 @@ import { enableProfilerCommitHooks, enableProfilerNestedUpdatePhase, enableSuspenseServerRenderer, - enableFundamentalAPI, enableSuspenseCallback, enableScopeAPI, enableDoubleInvokingEffects, @@ -53,7 +52,6 @@ import { MemoComponent, SimpleMemoComponent, SuspenseListComponent, - FundamentalComponent, ScopeComponent, OffscreenComponent, LegacyHiddenComponent, @@ -124,8 +122,6 @@ import { hideTextInstance, unhideInstance, unhideTextInstance, - unmountFundamentalComponent, - updateFundamentalComponent, commitHydratedContainer, commitHydratedSuspenseInstance, clearContainer, @@ -909,7 +905,6 @@ function commitLayoutEffectOnFiber( } case SuspenseListComponent: case IncompleteClassComponent: - case FundamentalComponent: case ScopeComponent: case OffscreenComponent: case LegacyHiddenComponent: @@ -1133,16 +1128,6 @@ function commitUnmount( } return; } - case FundamentalComponent: { - if (enableFundamentalAPI) { - const fundamentalInstance = current.stateNode; - if (fundamentalInstance !== null) { - unmountFundamentalComponent(fundamentalInstance); - current.stateNode = null; - } - } - return; - } case DehydratedFragment: { if (enableSuspenseCallback) { const hydrationCallbacks = finishedRoot.hydrationCallbacks; @@ -1271,8 +1256,7 @@ function commitContainer(finishedWork: Fiber) { switch (finishedWork.tag) { case ClassComponent: case HostComponent: - case HostText: - case FundamentalComponent: { + case HostText: { return; } case HostRoot: @@ -1388,11 +1372,6 @@ function commitPlacement(finishedWork: Fiber): void { parent = parentStateNode.containerInfo; isContainer = true; break; - case FundamentalComponent: - if (enableFundamentalAPI) { - parent = parentStateNode.instance; - isContainer = false; - } // eslint-disable-next-line-no-fallthrough default: invariant( @@ -1425,7 +1404,7 @@ function insertOrAppendPlacementNodeIntoContainer( ): void { const {tag} = node; const isHost = tag === HostComponent || tag === HostText; - if (isHost || (enableFundamentalAPI && tag === FundamentalComponent)) { + if (isHost) { const stateNode = isHost ? node.stateNode : node.stateNode.instance; if (before) { insertInContainerBefore(parent, stateNode, before); @@ -1456,7 +1435,7 @@ function insertOrAppendPlacementNode( ): void { const {tag} = node; const isHost = tag === HostComponent || tag === HostText; - if (isHost || (enableFundamentalAPI && tag === FundamentalComponent)) { + if (isHost) { const stateNode = isHost ? node.stateNode : node.stateNode.instance; if (before) { insertBefore(parent, stateNode, before); @@ -1521,11 +1500,6 @@ function unmountHostComponents( currentParent = parentStateNode.containerInfo; currentParentIsContainer = true; break findParent; - case FundamentalComponent: - if (enableFundamentalAPI) { - currentParent = parentStateNode.instance; - currentParentIsContainer = false; - } } parent = parent.return; } @@ -1553,27 +1527,6 @@ function unmountHostComponents( ); } // Don't visit children because we already visited them. - } else if (enableFundamentalAPI && node.tag === FundamentalComponent) { - const fundamentalNode = node.stateNode.instance; - commitNestedUnmounts( - finishedRoot, - node, - nearestMountedAncestor, - renderPriorityLevel, - ); - // After all the children have unmounted, it is now safe to remove the - // node from the tree. - if (currentParentIsContainer) { - removeChildFromContainer( - ((currentParent: any): Container), - (fundamentalNode: Instance), - ); - } else { - removeChild( - ((currentParent: any): Instance), - (fundamentalNode: Instance), - ); - } } else if ( enableSuspenseServerRenderer && node.tag === DehydratedFragment @@ -1849,14 +1802,6 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void { case IncompleteClassComponent: { return; } - case FundamentalComponent: { - if (enableFundamentalAPI) { - const fundamentalInstance = finishedWork.stateNode; - updateFundamentalComponent(fundamentalInstance); - return; - } - break; - } case ScopeComponent: { if (enableScopeAPI) { const scopeInstance = finishedWork.stateNode; diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.old.js b/packages/react-reconciler/src/ReactFiberCommitWork.old.js index d5ce4dd688d63..7a27bbc48f875 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.old.js @@ -33,7 +33,6 @@ import { enableProfilerCommitHooks, enableProfilerNestedUpdatePhase, enableSuspenseServerRenderer, - enableFundamentalAPI, enableSuspenseCallback, enableScopeAPI, enableDoubleInvokingEffects, @@ -53,7 +52,6 @@ import { MemoComponent, SimpleMemoComponent, SuspenseListComponent, - FundamentalComponent, ScopeComponent, OffscreenComponent, LegacyHiddenComponent, @@ -124,8 +122,6 @@ import { hideTextInstance, unhideInstance, unhideTextInstance, - unmountFundamentalComponent, - updateFundamentalComponent, commitHydratedContainer, commitHydratedSuspenseInstance, clearContainer, @@ -909,7 +905,6 @@ function commitLayoutEffectOnFiber( } case SuspenseListComponent: case IncompleteClassComponent: - case FundamentalComponent: case ScopeComponent: case OffscreenComponent: case LegacyHiddenComponent: @@ -1133,16 +1128,6 @@ function commitUnmount( } return; } - case FundamentalComponent: { - if (enableFundamentalAPI) { - const fundamentalInstance = current.stateNode; - if (fundamentalInstance !== null) { - unmountFundamentalComponent(fundamentalInstance); - current.stateNode = null; - } - } - return; - } case DehydratedFragment: { if (enableSuspenseCallback) { const hydrationCallbacks = finishedRoot.hydrationCallbacks; @@ -1271,8 +1256,7 @@ function commitContainer(finishedWork: Fiber) { switch (finishedWork.tag) { case ClassComponent: case HostComponent: - case HostText: - case FundamentalComponent: { + case HostText: { return; } case HostRoot: @@ -1388,11 +1372,6 @@ function commitPlacement(finishedWork: Fiber): void { parent = parentStateNode.containerInfo; isContainer = true; break; - case FundamentalComponent: - if (enableFundamentalAPI) { - parent = parentStateNode.instance; - isContainer = false; - } // eslint-disable-next-line-no-fallthrough default: invariant( @@ -1425,7 +1404,7 @@ function insertOrAppendPlacementNodeIntoContainer( ): void { const {tag} = node; const isHost = tag === HostComponent || tag === HostText; - if (isHost || (enableFundamentalAPI && tag === FundamentalComponent)) { + if (isHost) { const stateNode = isHost ? node.stateNode : node.stateNode.instance; if (before) { insertInContainerBefore(parent, stateNode, before); @@ -1456,7 +1435,7 @@ function insertOrAppendPlacementNode( ): void { const {tag} = node; const isHost = tag === HostComponent || tag === HostText; - if (isHost || (enableFundamentalAPI && tag === FundamentalComponent)) { + if (isHost) { const stateNode = isHost ? node.stateNode : node.stateNode.instance; if (before) { insertBefore(parent, stateNode, before); @@ -1521,11 +1500,6 @@ function unmountHostComponents( currentParent = parentStateNode.containerInfo; currentParentIsContainer = true; break findParent; - case FundamentalComponent: - if (enableFundamentalAPI) { - currentParent = parentStateNode.instance; - currentParentIsContainer = false; - } } parent = parent.return; } @@ -1553,27 +1527,6 @@ function unmountHostComponents( ); } // Don't visit children because we already visited them. - } else if (enableFundamentalAPI && node.tag === FundamentalComponent) { - const fundamentalNode = node.stateNode.instance; - commitNestedUnmounts( - finishedRoot, - node, - nearestMountedAncestor, - renderPriorityLevel, - ); - // After all the children have unmounted, it is now safe to remove the - // node from the tree. - if (currentParentIsContainer) { - removeChildFromContainer( - ((currentParent: any): Container), - (fundamentalNode: Instance), - ); - } else { - removeChild( - ((currentParent: any): Instance), - (fundamentalNode: Instance), - ); - } } else if ( enableSuspenseServerRenderer && node.tag === DehydratedFragment @@ -1849,14 +1802,6 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void { case IncompleteClassComponent: { return; } - case FundamentalComponent: { - if (enableFundamentalAPI) { - const fundamentalInstance = finishedWork.stateNode; - updateFundamentalComponent(fundamentalInstance); - return; - } - break; - } case ScopeComponent: { if (enableScopeAPI) { const scopeInstance = finishedWork.stateNode; diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.new.js b/packages/react-reconciler/src/ReactFiberCompleteWork.new.js index cd7ed4c4c180e..378c0006c33b8 100644 --- a/packages/react-reconciler/src/ReactFiberCompleteWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCompleteWork.new.js @@ -9,11 +9,7 @@ import type {Fiber} from './ReactInternalTypes'; import type {Lanes, Lane} from './ReactFiberLane.new'; -import type { - ReactFundamentalComponentInstance, - ReactScopeInstance, - ReactContext, -} from 'shared/ReactTypes'; +import type {ReactScopeInstance, ReactContext} from 'shared/ReactTypes'; import type {FiberRoot} from './ReactInternalTypes'; import type { Instance, @@ -54,7 +50,6 @@ import { SimpleMemoComponent, LazyComponent, IncompleteClassComponent, - FundamentalComponent, ScopeComponent, OffscreenComponent, LegacyHiddenComponent, @@ -92,10 +87,6 @@ import { createContainerChildSet, appendChildToContainerChildSet, finalizeContainerChildren, - getFundamentalComponentInstance, - mountFundamentalComponent, - cloneFundamentalInstance, - shouldUpdateFundamentalComponent, preparePortalMount, prepareScopeUpdate, } from './ReactFiberHostConfig'; @@ -134,7 +125,6 @@ import { enableSchedulerTracing, enableSuspenseCallback, enableSuspenseServerRenderer, - enableFundamentalAPI, enableScopeAPI, enableProfilerTimer, enableCache, @@ -148,7 +138,6 @@ import { getRenderTargetTime, subtreeRenderLanes, } from './ReactFiberWorkLoop.new'; -import {createFundamentalStateInstance} from './ReactFiberFundamental.new'; import { OffscreenLane, SomeRetryLane, @@ -219,8 +208,6 @@ if (supportsMutation) { while (node !== null) { if (node.tag === HostComponent || node.tag === HostText) { appendInitialChild(parent, node.stateNode); - } else if (enableFundamentalAPI && node.tag === FundamentalComponent) { - appendInitialChild(parent, node.stateNode.instance); } else if (node.tag === HostPortal) { // If we have a portal child, then we don't want to traverse // down its children. Instead, we'll get insertions from each child in @@ -330,15 +317,6 @@ if (supportsMutation) { instance = cloneHiddenTextInstance(instance, text, node); } appendInitialChild(parent, instance); - } else if (enableFundamentalAPI && node.tag === FundamentalComponent) { - let instance = node.stateNode.instance; - if (needsVisibilityToggle && isHidden) { - // This child is inside a timed out tree. Hide it. - const props = node.memoizedProps; - const type = node.type; - instance = cloneHiddenInstance(instance, type, props, node); - } - appendInitialChild(parent, instance); } else if (node.tag === HostPortal) { // If we have a portal child, then we don't want to traverse // down its children. Instead, we'll get insertions from each child in @@ -424,15 +402,6 @@ if (supportsMutation) { instance = cloneHiddenTextInstance(instance, text, node); } appendChildToContainerChildSet(containerChildSet, instance); - } else if (enableFundamentalAPI && node.tag === FundamentalComponent) { - let instance = node.stateNode.instance; - if (needsVisibilityToggle && isHidden) { - // This child is inside a timed out tree. Hide it. - const props = node.memoizedProps; - const type = node.type; - instance = cloneHiddenInstance(instance, type, props, node); - } - appendChildToContainerChildSet(containerChildSet, instance); } else if (node.tag === HostPortal) { // If we have a portal child, then we don't want to traverse // down its children. Instead, we'll get insertions from each child in @@ -1406,59 +1375,6 @@ function completeWork( bubbleProperties(workInProgress); return null; } - case FundamentalComponent: { - if (enableFundamentalAPI) { - const fundamentalImpl = workInProgress.type.impl; - let fundamentalInstance: ReactFundamentalComponentInstance< - any, - any, - > | null = workInProgress.stateNode; - - if (fundamentalInstance === null) { - const getInitialState = fundamentalImpl.getInitialState; - let fundamentalState; - if (getInitialState !== undefined) { - fundamentalState = getInitialState(newProps); - } - fundamentalInstance = workInProgress.stateNode = createFundamentalStateInstance( - workInProgress, - newProps, - fundamentalImpl, - fundamentalState || {}, - ); - const instance = ((getFundamentalComponentInstance( - fundamentalInstance, - ): any): Instance); - fundamentalInstance.instance = instance; - if (fundamentalImpl.reconcileChildren === false) { - bubbleProperties(workInProgress); - return null; - } - appendAllChildren(instance, workInProgress, false, false); - mountFundamentalComponent(fundamentalInstance); - } else { - // We fire update in commit phase - const prevProps = fundamentalInstance.props; - fundamentalInstance.prevProps = prevProps; - fundamentalInstance.props = newProps; - fundamentalInstance.currentFiber = workInProgress; - if (supportsPersistence) { - const instance = cloneFundamentalInstance(fundamentalInstance); - fundamentalInstance.instance = instance; - appendAllChildren(instance, workInProgress, false, false); - } - const shouldUpdate = shouldUpdateFundamentalComponent( - fundamentalInstance, - ); - if (shouldUpdate) { - markUpdate(workInProgress); - } - } - bubbleProperties(workInProgress); - return null; - } - break; - } case ScopeComponent: { if (enableScopeAPI) { if (current === null) { diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.old.js b/packages/react-reconciler/src/ReactFiberCompleteWork.old.js index 61c8a01bf27e3..55c5764910368 100644 --- a/packages/react-reconciler/src/ReactFiberCompleteWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCompleteWork.old.js @@ -9,11 +9,7 @@ import type {Fiber} from './ReactInternalTypes'; import type {Lanes, Lane} from './ReactFiberLane.old'; -import type { - ReactFundamentalComponentInstance, - ReactScopeInstance, - ReactContext, -} from 'shared/ReactTypes'; +import type {ReactScopeInstance, ReactContext} from 'shared/ReactTypes'; import type {FiberRoot} from './ReactInternalTypes'; import type { Instance, @@ -54,7 +50,6 @@ import { SimpleMemoComponent, LazyComponent, IncompleteClassComponent, - FundamentalComponent, ScopeComponent, OffscreenComponent, LegacyHiddenComponent, @@ -92,10 +87,6 @@ import { createContainerChildSet, appendChildToContainerChildSet, finalizeContainerChildren, - getFundamentalComponentInstance, - mountFundamentalComponent, - cloneFundamentalInstance, - shouldUpdateFundamentalComponent, preparePortalMount, prepareScopeUpdate, } from './ReactFiberHostConfig'; @@ -134,7 +125,6 @@ import { enableSchedulerTracing, enableSuspenseCallback, enableSuspenseServerRenderer, - enableFundamentalAPI, enableScopeAPI, enableProfilerTimer, enableCache, @@ -148,7 +138,6 @@ import { getRenderTargetTime, subtreeRenderLanes, } from './ReactFiberWorkLoop.old'; -import {createFundamentalStateInstance} from './ReactFiberFundamental.old'; import { OffscreenLane, SomeRetryLane, @@ -219,8 +208,6 @@ if (supportsMutation) { while (node !== null) { if (node.tag === HostComponent || node.tag === HostText) { appendInitialChild(parent, node.stateNode); - } else if (enableFundamentalAPI && node.tag === FundamentalComponent) { - appendInitialChild(parent, node.stateNode.instance); } else if (node.tag === HostPortal) { // If we have a portal child, then we don't want to traverse // down its children. Instead, we'll get insertions from each child in @@ -330,15 +317,6 @@ if (supportsMutation) { instance = cloneHiddenTextInstance(instance, text, node); } appendInitialChild(parent, instance); - } else if (enableFundamentalAPI && node.tag === FundamentalComponent) { - let instance = node.stateNode.instance; - if (needsVisibilityToggle && isHidden) { - // This child is inside a timed out tree. Hide it. - const props = node.memoizedProps; - const type = node.type; - instance = cloneHiddenInstance(instance, type, props, node); - } - appendInitialChild(parent, instance); } else if (node.tag === HostPortal) { // If we have a portal child, then we don't want to traverse // down its children. Instead, we'll get insertions from each child in @@ -424,15 +402,6 @@ if (supportsMutation) { instance = cloneHiddenTextInstance(instance, text, node); } appendChildToContainerChildSet(containerChildSet, instance); - } else if (enableFundamentalAPI && node.tag === FundamentalComponent) { - let instance = node.stateNode.instance; - if (needsVisibilityToggle && isHidden) { - // This child is inside a timed out tree. Hide it. - const props = node.memoizedProps; - const type = node.type; - instance = cloneHiddenInstance(instance, type, props, node); - } - appendChildToContainerChildSet(containerChildSet, instance); } else if (node.tag === HostPortal) { // If we have a portal child, then we don't want to traverse // down its children. Instead, we'll get insertions from each child in @@ -1406,59 +1375,6 @@ function completeWork( bubbleProperties(workInProgress); return null; } - case FundamentalComponent: { - if (enableFundamentalAPI) { - const fundamentalImpl = workInProgress.type.impl; - let fundamentalInstance: ReactFundamentalComponentInstance< - any, - any, - > | null = workInProgress.stateNode; - - if (fundamentalInstance === null) { - const getInitialState = fundamentalImpl.getInitialState; - let fundamentalState; - if (getInitialState !== undefined) { - fundamentalState = getInitialState(newProps); - } - fundamentalInstance = workInProgress.stateNode = createFundamentalStateInstance( - workInProgress, - newProps, - fundamentalImpl, - fundamentalState || {}, - ); - const instance = ((getFundamentalComponentInstance( - fundamentalInstance, - ): any): Instance); - fundamentalInstance.instance = instance; - if (fundamentalImpl.reconcileChildren === false) { - bubbleProperties(workInProgress); - return null; - } - appendAllChildren(instance, workInProgress, false, false); - mountFundamentalComponent(fundamentalInstance); - } else { - // We fire update in commit phase - const prevProps = fundamentalInstance.props; - fundamentalInstance.prevProps = prevProps; - fundamentalInstance.props = newProps; - fundamentalInstance.currentFiber = workInProgress; - if (supportsPersistence) { - const instance = cloneFundamentalInstance(fundamentalInstance); - fundamentalInstance.instance = instance; - appendAllChildren(instance, workInProgress, false, false); - } - const shouldUpdate = shouldUpdateFundamentalComponent( - fundamentalInstance, - ); - if (shouldUpdate) { - markUpdate(workInProgress); - } - } - bubbleProperties(workInProgress); - return null; - } - break; - } case ScopeComponent: { if (enableScopeAPI) { if (current === null) { diff --git a/packages/react-reconciler/src/ReactFiberFundamental.new.js b/packages/react-reconciler/src/ReactFiberFundamental.new.js deleted file mode 100644 index 0107a92ae468b..0000000000000 --- a/packages/react-reconciler/src/ReactFiberFundamental.new.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {Fiber} from './ReactInternalTypes'; -import type { - ReactFundamentalImpl, - ReactFundamentalComponentInstance, -} from 'shared/ReactTypes'; - -export function createFundamentalStateInstance( - currentFiber: Fiber, - props: Object, - impl: ReactFundamentalImpl, - state: Object, -): ReactFundamentalComponentInstance { - return { - currentFiber, - impl, - instance: null, - prevProps: null, - props, - state, - }; -} diff --git a/packages/react-reconciler/src/ReactFiberFundamental.old.js b/packages/react-reconciler/src/ReactFiberFundamental.old.js deleted file mode 100644 index 0107a92ae468b..0000000000000 --- a/packages/react-reconciler/src/ReactFiberFundamental.old.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {Fiber} from './ReactInternalTypes'; -import type { - ReactFundamentalImpl, - ReactFundamentalComponentInstance, -} from 'shared/ReactTypes'; - -export function createFundamentalStateInstance( - currentFiber: Fiber, - props: Object, - impl: ReactFundamentalImpl, - state: Object, -): ReactFundamentalComponentInstance { - return { - currentFiber, - impl, - instance: null, - prevProps: null, - props, - state, - }; -} diff --git a/packages/react-reconciler/src/ReactFiberHostConfigWithNoPersistence.js b/packages/react-reconciler/src/ReactFiberHostConfigWithNoPersistence.js index 2b58a0db4d7b0..d5f84cf43fd6d 100644 --- a/packages/react-reconciler/src/ReactFiberHostConfigWithNoPersistence.js +++ b/packages/react-reconciler/src/ReactFiberHostConfigWithNoPersistence.js @@ -24,7 +24,6 @@ function shim(...args: any) { // Persistence (when unsupported) export const supportsPersistence = false; export const cloneInstance = shim; -export const cloneFundamentalInstance = shim; export const createContainerChildSet = shim; export const appendChildToContainerChildSet = shim; export const finalizeContainerChildren = shim; diff --git a/packages/react-reconciler/src/ReactFiberReconciler.new.js b/packages/react-reconciler/src/ReactFiberReconciler.new.js index 70923424e8870..57107e964245d 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.new.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.new.js @@ -17,7 +17,6 @@ import type { PublicInstance, } from './ReactFiberHostConfig'; import type {RendererInspectionConfig} from './ReactFiberHostConfig'; -import {FundamentalComponent} from './ReactWorkTags'; import type {ReactNodeList} from 'shared/ReactTypes'; import type {Lane, LanePriority} from './ReactFiberLane.new'; import type {SuspenseState} from './ReactFiberSuspenseComponent.new'; @@ -460,9 +459,6 @@ export function findHostInstanceWithNoPortals( if (hostFiber === null) { return null; } - if (hostFiber.tag === FundamentalComponent) { - return hostFiber.stateNode.instance; - } return hostFiber.stateNode; } diff --git a/packages/react-reconciler/src/ReactFiberReconciler.old.js b/packages/react-reconciler/src/ReactFiberReconciler.old.js index 64bbea2c4070f..ba9a796f63002 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.old.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.old.js @@ -17,7 +17,6 @@ import type { PublicInstance, } from './ReactFiberHostConfig'; import type {RendererInspectionConfig} from './ReactFiberHostConfig'; -import {FundamentalComponent} from './ReactWorkTags'; import type {ReactNodeList} from 'shared/ReactTypes'; import type {Lane, LanePriority} from './ReactFiberLane.old'; import type {SuspenseState} from './ReactFiberSuspenseComponent.old'; @@ -460,9 +459,6 @@ export function findHostInstanceWithNoPortals( if (hostFiber === null) { return null; } - if (hostFiber.tag === FundamentalComponent) { - return hostFiber.stateNode.instance; - } return hostFiber.stateNode; } diff --git a/packages/react-reconciler/src/ReactFiberTreeReflection.js b/packages/react-reconciler/src/ReactFiberTreeReflection.js index 0b3448fec2b09..06356aa709fd0 100644 --- a/packages/react-reconciler/src/ReactFiberTreeReflection.js +++ b/packages/react-reconciler/src/ReactFiberTreeReflection.js @@ -22,11 +22,9 @@ import { HostRoot, HostPortal, HostText, - FundamentalComponent, SuspenseComponent, } from './ReactWorkTags'; import {NoFlags, Placement, Hydrating} from './ReactFiberFlags'; -import {enableFundamentalAPI} from 'shared/ReactFeatureFlags'; const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; @@ -297,11 +295,7 @@ export function findCurrentHostFiberWithNoPortals(parent: Fiber): Fiber | null { function findCurrentHostFiberWithNoPortalsImpl(node: Fiber) { // Next we'll drill down this component to find the first HostComponent/Text. - if ( - node.tag === HostComponent || - node.tag === HostText || - (enableFundamentalAPI && node.tag === FundamentalComponent) - ) { + if (node.tag === HostComponent || node.tag === HostText) { return node; } diff --git a/packages/react-reconciler/src/ReactWorkTags.js b/packages/react-reconciler/src/ReactWorkTags.js index 65dba28b367a3..fca4ffdce78b6 100644 --- a/packages/react-reconciler/src/ReactWorkTags.js +++ b/packages/react-reconciler/src/ReactWorkTags.js @@ -54,7 +54,6 @@ export const LazyComponent = 16; export const IncompleteClassComponent = 17; export const DehydratedFragment = 18; export const SuspenseListComponent = 19; -export const FundamentalComponent = 20; export const ScopeComponent = 21; export const OffscreenComponent = 22; export const LegacyHiddenComponent = 23; diff --git a/packages/react-reconciler/src/__tests__/ReactFiberFundamental-test.internal.js b/packages/react-reconciler/src/__tests__/ReactFiberFundamental-test.internal.js deleted file mode 100644 index f465226d20e53..0000000000000 --- a/packages/react-reconciler/src/__tests__/ReactFiberFundamental-test.internal.js +++ /dev/null @@ -1,231 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @emails react-core - */ - -'use strict'; - -let React; -let ReactNoop; -let Scheduler; -let ReactFeatureFlags; -let ReactTestRenderer; -let ReactDOM; -let ReactDOMServer; - -function createReactFundamentalComponent(fundamentalImpl) { - return React.unstable_createFundamental(fundamentalImpl); -} - -function init() { - jest.resetModules(); - ReactFeatureFlags = require('shared/ReactFeatureFlags'); - ReactFeatureFlags.enableFundamentalAPI = true; - React = require('react'); - Scheduler = require('scheduler'); -} - -function initNoopRenderer() { - init(); - ReactNoop = require('react-noop-renderer'); -} - -function initTestRenderer() { - init(); - ReactTestRenderer = require('react-test-renderer'); -} - -function initReactDOM() { - init(); - ReactDOM = require('react-dom'); -} - -function initReactDOMServer() { - init(); - ReactDOMServer = require('react-dom/server'); -} - -describe('ReactFiberFundamental', () => { - describe('NoopRenderer', () => { - beforeEach(() => { - initNoopRenderer(); - }); - - // @gate experimental - it('should render a simple fundamental component with a single child', () => { - const FundamentalComponent = createReactFundamentalComponent({ - reconcileChildren: true, - getInstance(context, props, state) { - const instance = { - children: [], - text: null, - type: 'test', - }; - return instance; - }, - }); - - const Test = ({children}) => ( - {children} - ); - - ReactNoop.render(Hello world); - expect(Scheduler).toFlushWithoutYielding(); - expect(ReactNoop).toMatchRenderedOutput(Hello world); - ReactNoop.render(Hello world again); - expect(Scheduler).toFlushWithoutYielding(); - expect(ReactNoop).toMatchRenderedOutput(Hello world again); - ReactNoop.render(null); - expect(Scheduler).toFlushWithoutYielding(); - expect(ReactNoop).toMatchRenderedOutput(null); - }); - }); - - describe('NoopTestRenderer', () => { - beforeEach(() => { - initTestRenderer(); - }); - - // @gate experimental - it('should render a simple fundamental component with a single child', () => { - const FundamentalComponent = createReactFundamentalComponent({ - reconcileChildren: true, - getInstance(context, props, state) { - const instance = { - children: [], - props, - type: 'test', - tag: 'INSTANCE', - }; - return instance; - }, - }); - - const Test = ({children}) => ( - {children} - ); - - const root = ReactTestRenderer.create(null); - root.update(Hello world); - expect(Scheduler).toFlushWithoutYielding(); - expect(root).toMatchRenderedOutput(Hello world); - root.update(Hello world again); - expect(Scheduler).toFlushWithoutYielding(); - expect(root).toMatchRenderedOutput(Hello world again); - root.update(null); - expect(Scheduler).toFlushWithoutYielding(); - expect(root).toMatchRenderedOutput(null); - }); - }); - - describe('ReactDOM', () => { - beforeEach(() => { - initReactDOM(); - }); - - // @gate experimental - it('should render a simple fundamental component with a single child', () => { - const FundamentalComponent = createReactFundamentalComponent({ - reconcileChildren: true, - getInstance(context, props, state) { - const instance = document.createElement('div'); - return instance; - }, - }); - - const Test = ({children}) => ( - {children} - ); - - const container = document.createElement('div'); - ReactDOM.render(Hello world, container); - expect(Scheduler).toFlushWithoutYielding(); - expect(container.innerHTML).toBe('
Hello world
'); - ReactDOM.render(Hello world again, container); - expect(Scheduler).toFlushWithoutYielding(); - expect(container.innerHTML).toBe('
Hello world again
'); - ReactDOM.render(null, container); - expect(Scheduler).toFlushWithoutYielding(); - expect(container.innerHTML).toBe(''); - }); - - // @gate experimental - it('should render a simple fundamental component without reconcileChildren', () => { - const FundamentalComponent = createReactFundamentalComponent({ - reconcileChildren: false, - getInstance(context, props, state) { - const instance = document.createElement('div'); - instance.textContent = 'Hello world'; - return instance; - }, - }); - - const Test = () => ; - - const container = document.createElement('div'); - ReactDOM.render(, container); - expect(Scheduler).toFlushWithoutYielding(); - expect(container.innerHTML).toBe('
Hello world
'); - // Children should be ignored - ReactDOM.render(Hello world again, container); - expect(Scheduler).toFlushWithoutYielding(); - expect(container.innerHTML).toBe('
Hello world
'); - ReactDOM.render(null, container); - expect(Scheduler).toFlushWithoutYielding(); - expect(container.innerHTML).toBe(''); - }); - }); - - describe('ReactDOMServer', () => { - beforeEach(() => { - initReactDOMServer(); - }); - - // @gate experimental - it('should render a simple fundamental component with a single child', () => { - const getInstance = jest.fn(); - const FundamentalComponent = createReactFundamentalComponent({ - reconcileChildren: true, - getInstance, - getServerSideString(context, props) { - return `
`; - }, - getServerSideStringClose(context, props) { - return `
`; - }, - }); - - const Test = ({children}) => ( - {children} - ); - - expect(getInstance).not.toBeCalled(); - let output = ReactDOMServer.renderToString(Hello world); - expect(output).toBe('
Hello world
'); - output = ReactDOMServer.renderToString(Hello world again); - expect(output).toBe('
Hello world again
'); - }); - - // @gate experimental - it('should render a simple fundamental component without reconcileChildren', () => { - const FundamentalComponent = createReactFundamentalComponent({ - reconcileChildren: false, - getServerSideString(context, props) { - return `
Hello world
`; - }, - }); - - const Test = () => ; - - let output = ReactDOMServer.renderToString(); - expect(output).toBe('
Hello world
'); - // Children should be ignored - output = ReactDOMServer.renderToString(Hello world again); - expect(output).toBe('
Hello world
'); - }); - }); -}); diff --git a/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js b/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js index b9ffc05725210..14e43a8222989 100644 --- a/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js +++ b/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js @@ -62,12 +62,6 @@ export const warnsIfNotActing = $$$hostConfig.warnsIfNotActing; export const supportsMutation = $$$hostConfig.supportsMutation; export const supportsPersistence = $$$hostConfig.supportsPersistence; export const supportsHydration = $$$hostConfig.supportsHydration; -export const getFundamentalComponentInstance = - $$$hostConfig.getFundamentalComponentInstance; -export const mountFundamentalComponent = - $$$hostConfig.mountFundamentalComponent; -export const shouldUpdateFundamentalComponent = - $$$hostConfig.shouldUpdateFundamentalComponent; export const getInstanceFromNode = $$$hostConfig.getInstanceFromNode; export const isOpaqueHydratingObject = $$$hostConfig.isOpaqueHydratingObject; export const makeOpaqueHydratingObject = @@ -112,10 +106,6 @@ export const hideInstance = $$$hostConfig.hideInstance; export const hideTextInstance = $$$hostConfig.hideTextInstance; export const unhideInstance = $$$hostConfig.unhideInstance; export const unhideTextInstance = $$$hostConfig.unhideTextInstance; -export const updateFundamentalComponent = - $$$hostConfig.updateFundamentalComponent; -export const unmountFundamentalComponent = - $$$hostConfig.unmountFundamentalComponent; export const clearContainer = $$$hostConfig.clearContainer; // ------------------- @@ -131,7 +121,6 @@ export const finalizeContainerChildren = export const replaceContainerChildren = $$$hostConfig.replaceContainerChildren; export const cloneHiddenInstance = $$$hostConfig.cloneHiddenInstance; export const cloneHiddenTextInstance = $$$hostConfig.cloneHiddenTextInstance; -export const cloneFundamentalInstance = $$$hostConfig.cloneInstance; // ------------------- // Hydration diff --git a/packages/react-test-renderer/src/ReactTestHostConfig.js b/packages/react-test-renderer/src/ReactTestHostConfig.js index 5adf1ac406e90..6110a0de8c58d 100644 --- a/packages/react-test-renderer/src/ReactTestHostConfig.js +++ b/packages/react-test-renderer/src/ReactTestHostConfig.js @@ -7,8 +7,6 @@ * @flow */ -import type {ReactFundamentalComponentInstance} from 'shared/ReactTypes'; - import {REACT_OPAQUE_ID_TYPE} from 'shared/ReactSymbols'; export type Type = string; @@ -299,54 +297,6 @@ export function unhideTextInstance( textInstance.isHidden = false; } -export function getFundamentalComponentInstance( - fundamentalInstance: ReactFundamentalComponentInstance, -): Instance { - const {impl, props, state} = fundamentalInstance; - return impl.getInstance(null, props, state); -} - -export function mountFundamentalComponent( - fundamentalInstance: ReactFundamentalComponentInstance, -): void { - const {impl, instance, props, state} = fundamentalInstance; - const onMount = impl.onMount; - if (onMount !== undefined) { - onMount(null, instance, props, state); - } -} - -export function shouldUpdateFundamentalComponent( - fundamentalInstance: ReactFundamentalComponentInstance, -): boolean { - const {impl, prevProps, props, state} = fundamentalInstance; - const shouldUpdate = impl.shouldUpdate; - if (shouldUpdate !== undefined) { - return shouldUpdate(null, prevProps, props, state); - } - return true; -} - -export function updateFundamentalComponent( - fundamentalInstance: ReactFundamentalComponentInstance, -): void { - const {impl, instance, prevProps, props, state} = fundamentalInstance; - const onUpdate = impl.onUpdate; - if (onUpdate !== undefined) { - onUpdate(null, instance, prevProps, props, state); - } -} - -export function unmountFundamentalComponent( - fundamentalInstance: ReactFundamentalComponentInstance, -): void { - const {impl, instance, props, state} = fundamentalInstance; - const onUnmount = impl.onUnmount; - if (onUnmount !== undefined) { - onUnmount(null, instance, props, state); - } -} - export function getInstanceFromNode(mockNode: Object) { const instance = nodeToInstanceMap.get(mockNode); if (instance !== undefined) { diff --git a/packages/react/index.js b/packages/react/index.js index 80e6591171b5c..5319bb80be756 100644 --- a/packages/react/index.js +++ b/packages/react/index.js @@ -79,7 +79,6 @@ export { SuspenseList, SuspenseList as unstable_SuspenseList, unstable_LegacyHidden, - unstable_createFundamental, unstable_Scope, unstable_useOpaqueIdentifier, unstable_getCacheForType, diff --git a/packages/react/src/React.js b/packages/react/src/React.js index 84490ef902c97..70c92ff86820e 100644 --- a/packages/react/src/React.js +++ b/packages/react/src/React.js @@ -58,7 +58,6 @@ import { } from './ReactElementValidator'; import {createMutableSource} from './ReactMutableSource'; import ReactSharedInternals from './ReactSharedInternals'; -import {createFundamental} from './ReactFundamental'; import {startTransition} from './ReactStartTransition'; // TODO: Move this branching into the other module instead and just re-export. @@ -116,8 +115,6 @@ export { getCacheForType as unstable_getCacheForType, useCacheRefresh as unstable_useCacheRefresh, REACT_CACHE_TYPE as unstable_Cache, - // enableFundamentalAPI - createFundamental as unstable_createFundamental, // enableScopeAPI REACT_SCOPE_TYPE as unstable_Scope, useOpaqueIdentifier as unstable_useOpaqueIdentifier, diff --git a/packages/react/src/ReactFundamental.js b/packages/react/src/ReactFundamental.js deleted file mode 100644 index ba5b220bc764f..0000000000000 --- a/packages/react/src/ReactFundamental.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * @flow - */ - -import type { - ReactFundamentalImpl, - ReactFundamentalComponent, -} from 'shared/ReactTypes'; -import {REACT_FUNDAMENTAL_TYPE} from 'shared/ReactSymbols'; -import {hasBadMapPolyfill} from './BadMapPolyfill'; - -export function createFundamental( - impl: ReactFundamentalImpl, -): ReactFundamentalComponent { - // We use responder as a Map key later on. When we have a bad - // polyfill, then we can't use it as a key as the polyfill tries - // to add a property to the object. - if (__DEV__ && !hasBadMapPolyfill) { - Object.freeze(impl); - } - const fundamentalComponent = { - $$typeof: REACT_FUNDAMENTAL_TYPE, - impl, - }; - if (__DEV__) { - Object.freeze(fundamentalComponent); - } - return fundamentalComponent; -} diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 53f9b744cb9c3..842bbe4dfa616 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -60,9 +60,6 @@ export const enableSchedulerDebugging = false; // Disable javascript: URL strings in href for XSS protection. export const disableJavaScriptURLs = false; -// Experimental Host Component support. -export const enableFundamentalAPI = false; - // Experimental Scope support. export const enableScopeAPI = false; diff --git a/packages/shared/ReactSymbols.js b/packages/shared/ReactSymbols.js index d490ab417c211..c2fcba6324410 100644 --- a/packages/shared/ReactSymbols.js +++ b/packages/shared/ReactSymbols.js @@ -25,7 +25,6 @@ export let REACT_SUSPENSE_TYPE = 0xead1; export let REACT_SUSPENSE_LIST_TYPE = 0xead8; export let REACT_MEMO_TYPE = 0xead3; export let REACT_LAZY_TYPE = 0xead4; -export let REACT_FUNDAMENTAL_TYPE = 0xead5; export let REACT_SCOPE_TYPE = 0xead7; export let REACT_OPAQUE_ID_TYPE = 0xeae0; export let REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; @@ -47,7 +46,6 @@ if (typeof Symbol === 'function' && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); REACT_MEMO_TYPE = symbolFor('react.memo'); REACT_LAZY_TYPE = symbolFor('react.lazy'); - REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); REACT_SCOPE_TYPE = symbolFor('react.scope'); REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); diff --git a/packages/shared/ReactTypes.js b/packages/shared/ReactTypes.js index 99e1bbb9bcd46..01708f731e9a9 100644 --- a/packages/shared/ReactTypes.js +++ b/packages/shared/ReactTypes.js @@ -92,52 +92,6 @@ export const DiscreteEvent: EventPriority = 0; export const UserBlockingEvent: EventPriority = 1; export const ContinuousEvent: EventPriority = 2; -export type ReactFundamentalComponentInstance = {| - currentFiber: Object, - instance: mixed, - prevProps: null | Object, - props: Object, - impl: ReactFundamentalImpl, - state: Object, -|}; - -export type ReactFundamentalImpl = { - displayName: string, - reconcileChildren: boolean, - getInitialState?: (props: Object) => Object, - getInstance: (context: C, props: Object, state: Object) => H, - getServerSideString?: (context: C, props: Object) => string, - getServerSideStringClose?: (context: C, props: Object) => string, - onMount: (context: C, instance: mixed, props: Object, state: Object) => void, - shouldUpdate?: ( - context: C, - prevProps: null | Object, - nextProps: Object, - state: Object, - ) => boolean, - onUpdate?: ( - context: C, - instance: mixed, - prevProps: null | Object, - nextProps: Object, - state: Object, - ) => void, - onUnmount?: ( - context: C, - instance: mixed, - props: Object, - state: Object, - ) => void, - onHydrate?: (context: C, props: Object, state: Object) => boolean, - onFocus?: (context: C, props: Object, state: Object) => boolean, - ... -}; - -export type ReactFundamentalComponent = {| - $$typeof: Symbol | number, - impl: ReactFundamentalImpl, -|}; - export type ReactScope = {| $$typeof: Symbol | number, |}; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index a230930cb0a6a..1200892cee3f5 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -28,7 +28,6 @@ export const disableJavaScriptURLs = false; export const disableInputAttributeSyncing = false; export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__; export const warnAboutDeprecatedLifecycles = true; -export const enableFundamentalAPI = false; export const enableScopeAPI = false; export const enableCreateEventHandleAPI = false; export const warnAboutUnmockedScheduler = true; diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index 0dc9bed575843..3eb2d5e718f9a 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -27,7 +27,6 @@ export const enableCache = false; export const disableJavaScriptURLs = false; export const disableInputAttributeSyncing = false; export const enableSchedulerDebugging = false; -export const enableFundamentalAPI = false; export const enableScopeAPI = false; export const enableCreateEventHandleAPI = false; export const warnAboutUnmockedScheduler = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 5652b66a0b835..0e95ccae41092 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -27,7 +27,6 @@ export const enableCache = __EXPERIMENTAL__; export const disableJavaScriptURLs = false; export const disableInputAttributeSyncing = false; export const enableSchedulerDebugging = false; -export const enableFundamentalAPI = false; export const enableScopeAPI = false; export const enableCreateEventHandleAPI = false; export const warnAboutUnmockedScheduler = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js index 8962bcce36a41..ef7e948b2e189 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js @@ -27,7 +27,6 @@ export const enableCache = false; export const disableJavaScriptURLs = false; export const disableInputAttributeSyncing = false; export const enableSchedulerDebugging = false; -export const enableFundamentalAPI = false; export const enableScopeAPI = false; export const enableCreateEventHandleAPI = false; export const warnAboutUnmockedScheduler = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 7905485bce686..756c38694ec7f 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -27,7 +27,6 @@ export const enableCache = false; export const enableSchedulerDebugging = false; export const disableJavaScriptURLs = false; export const disableInputAttributeSyncing = false; -export const enableFundamentalAPI = false; export const enableScopeAPI = true; export const enableCreateEventHandleAPI = false; export const warnAboutUnmockedScheduler = true; diff --git a/packages/shared/forks/ReactFeatureFlags.testing.js b/packages/shared/forks/ReactFeatureFlags.testing.js index c1a20dd91a324..d2240049e0a4d 100644 --- a/packages/shared/forks/ReactFeatureFlags.testing.js +++ b/packages/shared/forks/ReactFeatureFlags.testing.js @@ -27,7 +27,6 @@ export const enableCache = false; export const disableJavaScriptURLs = false; export const disableInputAttributeSyncing = false; export const enableSchedulerDebugging = false; -export const enableFundamentalAPI = false; export const enableScopeAPI = false; export const enableCreateEventHandleAPI = false; export const warnAboutUnmockedScheduler = false; diff --git a/packages/shared/forks/ReactFeatureFlags.testing.www.js b/packages/shared/forks/ReactFeatureFlags.testing.www.js index c274d6a376450..e80dfde724d28 100644 --- a/packages/shared/forks/ReactFeatureFlags.testing.www.js +++ b/packages/shared/forks/ReactFeatureFlags.testing.www.js @@ -27,7 +27,6 @@ export const enableCache = false; export const disableJavaScriptURLs = true; export const disableInputAttributeSyncing = false; export const enableSchedulerDebugging = false; -export const enableFundamentalAPI = false; export const enableScopeAPI = true; export const enableCreateEventHandleAPI = true; export const warnAboutUnmockedScheduler = true; diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index 2b1ba37ee8486..640b0d6f3e303 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -71,8 +71,6 @@ export const disableModulePatternComponents = true; export const enableCreateEventHandleAPI = true; -export const enableFundamentalAPI = false; - export const enableScopeAPI = true; export const warnAboutUnmockedScheduler = true; diff --git a/packages/shared/isValidElementType.js b/packages/shared/isValidElementType.js index 0a361c4a22dec..7ad6b0766a663 100644 --- a/packages/shared/isValidElementType.js +++ b/packages/shared/isValidElementType.js @@ -19,7 +19,6 @@ import { REACT_SUSPENSE_LIST_TYPE, REACT_MEMO_TYPE, REACT_LAZY_TYPE, - REACT_FUNDAMENTAL_TYPE, REACT_SCOPE_TYPE, REACT_LEGACY_HIDDEN_TYPE, REACT_CACHE_TYPE, @@ -58,7 +57,6 @@ export default function isValidElementType(type: mixed) { type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || - type.$$typeof === REACT_FUNDAMENTAL_TYPE || // This needs to include all possible module reference object // types supported by any Flight configuration anywhere since // we don't know which Flight build this will end up being used