Skip to content

Commit

Permalink
Remove the Fundamental internals (#20745)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Feb 5, 2021
1 parent eeb1325 commit 4ecf119
Show file tree
Hide file tree
Showing 41 changed files with 12 additions and 1,092 deletions.
20 changes: 0 additions & 20 deletions packages/react-art/src/ReactARTHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down
3 changes: 0 additions & 3 deletions packages/react-devtools-shared/src/backend/ReactSymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)';

Expand Down
64 changes: 0 additions & 64 deletions packages/react-dom/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -64,7 +63,6 @@ import {retryIfBlockedOn} from '../events/ReactDOMEventReplaying';

import {
enableSuspenseServerRenderer,
enableFundamentalAPI,
enableCreateEventHandleAPI,
enableScopeAPI,
} from 'shared/ReactFeatureFlags';
Expand Down Expand Up @@ -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;
}
Expand Down
39 changes: 0 additions & 39 deletions packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
disableLegacyContext,
disableModulePatternComponents,
enableSuspenseServerRenderer,
enableFundamentalAPI,
enableScopeAPI,
} from 'shared/ReactFeatureFlags';

Expand All @@ -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';
Expand Down Expand Up @@ -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<any, any> = (nextChild: any)
Expand Down
10 changes: 1 addition & 9 deletions packages/react-dom/src/shared/ReactDOMTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<EventTarget>) => void,
Expand Down
24 changes: 0 additions & 24 deletions packages/react-native-renderer/src/ReactFabricHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down
20 changes: 0 additions & 20 deletions packages/react-native-renderer/src/ReactNativeHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down
51 changes: 0 additions & 51 deletions packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
},
Expand Down
35 changes: 1 addition & 34 deletions packages/react-reconciler/src/ReactFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -25,7 +20,6 @@ import type {OffscreenProps} from './ReactFiberOffscreenComponent';
import invariant from 'shared/invariant';
import {
enableProfilerTimer,
enableFundamentalAPI,
enableScopeAPI,
enableCache,
} from 'shared/ReactFeatureFlags';
Expand All @@ -51,7 +45,6 @@ import {
MemoComponent,
SimpleMemoComponent,
LazyComponent,
FundamentalComponent,
ScopeComponent,
OffscreenComponent,
LegacyHiddenComponent,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 = '';
Expand Down Expand Up @@ -618,20 +599,6 @@ export function createFiberFromFragment(
return fiber;
}

export function createFiberFromFundamental(
fundamentalComponent: ReactFundamentalComponent<any, any>,
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,
Expand Down
Loading

0 comments on commit 4ecf119

Please sign in to comment.