Skip to content

Commit c10e362

Browse files
committed
Move ReactDOMLegacy implementation into RootFB
Only the FB entry point has legacy mode now so we can move the remaining code in there.
1 parent 48ec17b commit c10e362

File tree

10 files changed

+139
-476
lines changed

10 files changed

+139
-476
lines changed

packages/react-devtools-shell/src/app/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ function mountStrictApp(App) {
6969
}
7070

7171
function mountLegacyApp(App: () => React$Node) {
72+
// $FlowFixMe[prop-missing]: These are removed in 19.
7273
const {render, unmountComponentAtNode} = require('react-dom');
7374

7475
function LegacyRender() {
@@ -77,8 +78,10 @@ function mountLegacyApp(App: () => React$Node) {
7778

7879
const container = createContainer();
7980

81+
// $FlowFixMe[not-a-function]: These are removed in 19.
8082
render(createElement(LegacyRender), container);
8183

84+
// $FlowFixMe: These are removed in 19.
8285
unmountFunctions.push(() => unmountComponentAtNode(container));
8386
}
8487

packages/react-devtools-shell/src/e2e-regression/app-legacy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function mountApp(App: () => React$Node) {
1515

1616
((document.body: any): HTMLBodyElement).appendChild(container);
1717

18+
// $FlowFixMe[prop-missing]: These are removed in 19.
1819
ReactDOM.render(<App />, container);
1920
}
2021
function mountTestApp() {

packages/react-dom/index.classic.fb.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ Object.assign((Internals: any), {
2020

2121
export {
2222
createPortal,
23-
findDOMNode,
2423
flushSync,
25-
unmountComponentAtNode,
2624
unstable_createEventHandle,
27-
unstable_renderSubtreeIntoContainer,
2825
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
2926
useFormStatus,
3027
useFormState,
@@ -42,6 +39,9 @@ export {
4239
hydrateRoot,
4340
render,
4441
unstable_batchedUpdates,
42+
findDOMNode,
43+
unstable_renderSubtreeIntoContainer,
44+
unmountComponentAtNode,
4545
} from './src/client/ReactDOMRootFB';
4646

4747
export {Internals as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED};

packages/react-dom/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ export {
1515
createRoot,
1616
hydrateRoot,
1717
flushSync,
18-
render,
19-
unmountComponentAtNode,
2018
unstable_batchedUpdates,
2119
unstable_createEventHandle,
22-
unstable_renderSubtreeIntoContainer,
2320
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
2421
useFormStatus,
2522
useFormState,

packages/react-dom/index.stable.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ export {
1313
createRoot,
1414
hydrateRoot,
1515
flushSync,
16-
render,
17-
unmountComponentAtNode,
1816
unstable_batchedUpdates,
19-
unstable_renderSubtreeIntoContainer,
2017
useFormStatus,
2118
useFormState,
2219
prefetchDNS,

packages/react-dom/src/ReactDOMSharedInternals.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* @flow
88
*/
99

10-
import type {FindDOMNodeType} from './client/ReactDOMLegacy.js';
1110
import type {HostDispatcher} from './shared/ReactDOMTypes';
1211

1312
type InternalsType = {
@@ -16,7 +15,11 @@ type InternalsType = {
1615
ReactDOMCurrentDispatcher: {
1716
current: HostDispatcher,
1817
},
19-
findDOMNode: null | FindDOMNodeType,
18+
findDOMNode:
19+
| null
20+
| ((
21+
componentOrElement: React$Component<any, any>,
22+
) => null | Element | Text),
2023
};
2124

2225
function noop() {}

packages/react-dom/src/client/ReactDOM.js

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,12 @@
88
*/
99

1010
import type {ReactNodeList} from 'shared/ReactTypes';
11-
import type {
12-
Container,
13-
PublicInstance,
14-
} from 'react-dom-bindings/src/client/ReactFiberConfigDOM';
1511
import type {
1612
RootType,
1713
HydrateRootOptions,
1814
CreateRootOptions,
1915
} from './ReactDOMRoot';
2016

21-
import {
22-
findDOMNode,
23-
render,
24-
unstable_renderSubtreeIntoContainer,
25-
unmountComponentAtNode,
26-
} from './ReactDOMLegacy';
2717
import {
2818
createRoot as createRootImpl,
2919
hydrateRoot as hydrateRootImpl,
@@ -35,6 +25,7 @@ import {
3525
flushSync as flushSyncWithoutWarningIfAlreadyRendering,
3626
isAlreadyRendering,
3727
injectIntoDevTools,
28+
findHostInstance,
3829
} from 'react-reconciler/src/ReactFiberReconciler';
3930
import {runWithPriority} from 'react-reconciler/src/ReactEventPriorities';
4031
import {createPortal as createPortalImpl} from 'react-reconciler/src/ReactPortal';
@@ -99,20 +90,6 @@ function createPortal(
9990
return createPortalImpl(children, container, null, key);
10091
}
10192

102-
function renderSubtreeIntoContainer(
103-
parentComponent: React$Component<any, any>,
104-
element: React$Element<any>,
105-
containerNode: Container,
106-
callback: ?Function,
107-
): React$Component<any, any> | PublicInstance | null {
108-
return unstable_renderSubtreeIntoContainer(
109-
parentComponent,
110-
element,
111-
containerNode,
112-
callback,
113-
);
114-
}
115-
11693
function createRoot(
11794
container: Element | Document | DocumentFragment,
11895
options?: CreateRootOptions,
@@ -163,6 +140,12 @@ function flushSync<R>(fn: (() => R) | void): R | void {
163140
return flushSyncWithoutWarningIfAlreadyRendering(fn);
164141
}
165142

143+
function findDOMNode(
144+
componentOrElement: React$Component<any, any>,
145+
): null | Element | Text {
146+
return findHostInstance(componentOrElement);
147+
}
148+
166149
// Expose findDOMNode on internals
167150
Internals.findDOMNode = findDOMNode;
168151

@@ -178,15 +161,9 @@ export {
178161
unstable_batchedUpdates,
179162
flushSync,
180163
ReactVersion as version,
181-
// Disabled behind disableLegacyReactDOMAPIs
182-
findDOMNode,
183-
render,
184-
unmountComponentAtNode,
185164
// exposeConcurrentModeAPIs
186165
createRoot,
187166
hydrateRoot,
188-
// Disabled behind disableUnstableRenderSubtreeIntoContainer
189-
renderSubtreeIntoContainer as unstable_renderSubtreeIntoContainer,
190167
// enableCreateEventHandleAPI
191168
createEventHandle as unstable_createEventHandle,
192169
// TODO: Remove this once callers migrate to alternatives.

0 commit comments

Comments
 (0)