Skip to content

Commit

Permalink
The cost of the separate file is not really warranted. Will use featu…
Browse files Browse the repository at this point in the history
…re flag to scope build specific implementations
  • Loading branch information
gnoff committed Apr 3, 2024
1 parent 8b62c73 commit 75941c4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 219 deletions.
2 changes: 1 addition & 1 deletion packages/react-dom/index.classic.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export {
preinit,
preinitModule,
version,
} from './src/client/ReactDOMFB';
} from './src/client/ReactDOM';

export {
createRoot,
Expand Down
28 changes: 27 additions & 1 deletion packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ import type {
CreateRootOptions,
} from './ReactDOMRoot';

import {disableLegacyMode} from 'shared/ReactFeatureFlags';
import {
createRoot as createRootImpl,
hydrateRoot as hydrateRootImpl,
isValidContainer,
} from './ReactDOMRoot';
import {createEventHandle} from 'react-dom-bindings/src/client/ReactDOMEventHandle';
import {flushSync} from '../shared/ReactDOMFlushSync';
import {flushSync as flushSyncIsomorphic} from '../shared/ReactDOMFlushSync';

import {
flushSyncFromReconciler as flushSyncWithoutWarningIfAlreadyRendering,
isAlreadyRendering,
injectIntoDevTools,
findHostInstance,
} from 'react-reconciler/src/ReactFiberReconciler';
Expand Down Expand Up @@ -120,6 +123,29 @@ function hydrateRoot(
return hydrateRootImpl(container, initialChildren, options);
}

// Overload the definition to the two valid signatures.
// Warning, this opts-out of checking the function body.
declare function flushSyncFromReconciler<R>(fn: () => R): R;
// eslint-disable-next-line no-redeclare
declare function flushSyncFromReconciler(): void;
// eslint-disable-next-line no-redeclare
function flushSyncFromReconciler<R>(fn: (() => R) | void): R | void {
if (__DEV__) {
if (isAlreadyRendering()) {
console.error(
'flushSync was called from inside a lifecycle method. React cannot ' +
'flush when React is already rendering. Consider moving this call to ' +
'a scheduler task or micro task.',
);
}
}
return flushSyncWithoutWarningIfAlreadyRendering(fn);
}

const flushSync: typeof flushSyncIsomorphic = disableLegacyMode
? flushSyncIsomorphic
: flushSyncFromReconciler;

function findDOMNode(
componentOrElement: React$Component<any, any>,
): null | Element | Text {
Expand Down
217 changes: 0 additions & 217 deletions packages/react-dom/src/client/ReactDOMFB.js

This file was deleted.

0 comments on commit 75941c4

Please sign in to comment.