Skip to content

Commit

Permalink
Move ReactDOMLegacy implementation into RootFB
Browse files Browse the repository at this point in the history
Only the FB entry point has legacy mode now so we can move the remaining
code in there.
  • Loading branch information
sebmarkbage committed Apr 2, 2024
1 parent 48ec17b commit 360f9f7
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 471 deletions.
6 changes: 3 additions & 3 deletions packages/react-dom/index.classic.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ Object.assign((Internals: any), {

export {
createPortal,
findDOMNode,
flushSync,
unmountComponentAtNode,
unstable_createEventHandle,
unstable_renderSubtreeIntoContainer,
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
useFormStatus,
useFormState,
Expand All @@ -42,6 +39,9 @@ export {
hydrateRoot,
render,
unstable_batchedUpdates,
findDOMNode,
unstable_renderSubtreeIntoContainer,
unmountComponentAtNode,
} from './src/client/ReactDOMRootFB';

export {Internals as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED};
3 changes: 0 additions & 3 deletions packages/react-dom/index.stable.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ export {
createRoot,
hydrateRoot,
flushSync,
render,
unmountComponentAtNode,
unstable_batchedUpdates,
unstable_renderSubtreeIntoContainer,
useFormStatus,
useFormState,
prefetchDNS,
Expand Down
37 changes: 7 additions & 30 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,12 @@
*/

import type {ReactNodeList} from 'shared/ReactTypes';
import type {
Container,
PublicInstance,
} from 'react-dom-bindings/src/client/ReactFiberConfigDOM';
import type {
RootType,
HydrateRootOptions,
CreateRootOptions,
} from './ReactDOMRoot';

import {
findDOMNode,
render,
unstable_renderSubtreeIntoContainer,
unmountComponentAtNode,
} from './ReactDOMLegacy';
import {
createRoot as createRootImpl,
hydrateRoot as hydrateRootImpl,
Expand All @@ -35,6 +25,7 @@ import {
flushSync as flushSyncWithoutWarningIfAlreadyRendering,
isAlreadyRendering,
injectIntoDevTools,
findHostInstance,
} from 'react-reconciler/src/ReactFiberReconciler';
import {runWithPriority} from 'react-reconciler/src/ReactEventPriorities';
import {createPortal as createPortalImpl} from 'react-reconciler/src/ReactPortal';
Expand Down Expand Up @@ -99,20 +90,6 @@ function createPortal(
return createPortalImpl(children, container, null, key);
}

function renderSubtreeIntoContainer(
parentComponent: React$Component<any, any>,
element: React$Element<any>,
containerNode: Container,
callback: ?Function,
): React$Component<any, any> | PublicInstance | null {
return unstable_renderSubtreeIntoContainer(
parentComponent,
element,
containerNode,
callback,
);
}

function createRoot(
container: Element | Document | DocumentFragment,
options?: CreateRootOptions,
Expand Down Expand Up @@ -163,6 +140,12 @@ function flushSync<R>(fn: (() => R) | void): R | void {
return flushSyncWithoutWarningIfAlreadyRendering(fn);
}

function findDOMNode(
componentOrElement: Element | ?React$Component<any, any>,
): null | Element | Text {
return findHostInstance(componentOrElement);
}

// Expose findDOMNode on internals
Internals.findDOMNode = findDOMNode;

Expand All @@ -178,15 +161,9 @@ export {
unstable_batchedUpdates,
flushSync,
ReactVersion as version,
// Disabled behind disableLegacyReactDOMAPIs
findDOMNode,
render,
unmountComponentAtNode,
// exposeConcurrentModeAPIs
createRoot,
hydrateRoot,
// Disabled behind disableUnstableRenderSubtreeIntoContainer
renderSubtreeIntoContainer as unstable_renderSubtreeIntoContainer,
// enableCreateEventHandleAPI
createEventHandle as unstable_createEventHandle,
// TODO: Remove this once callers migrate to alternatives.
Expand Down
Loading

0 comments on commit 360f9f7

Please sign in to comment.