diff --git a/packages/react-dom/src/client/ReactDOM.js b/packages/react-dom/src/client/ReactDOM.js index 938cf98ca6b0a..7a7b4de04a5cb 100644 --- a/packages/react-dom/src/client/ReactDOM.js +++ b/packages/react-dom/src/client/ReactDOM.js @@ -39,6 +39,7 @@ import { findHostInstanceWithWarning, flushPassiveEffects, IsThisRendererActing, + attemptSynchronousHydration, } from 'react-reconciler/inline.dom'; import {createPortal as createPortalImpl} from 'shared/ReactPortal'; import {canUseDOM} from 'shared/ExecutionEnvironment'; @@ -74,6 +75,7 @@ import { } from './ReactDOMComponentTree'; import {restoreControlledState} from './ReactDOMComponent'; import {dispatchEvent} from '../events/ReactDOMEventListener'; +import {setAttemptSynchronousHydration} from '../events/ReactDOMEventReplaying'; import {eagerlyTrapReplayableEvents} from '../events/ReactDOMEventReplaying'; import { ELEMENT_NODE, @@ -83,6 +85,8 @@ import { } from '../shared/HTMLNodeType'; import {ROOT_ATTRIBUTE_NAME} from '../shared/DOMProperty'; +setAttemptSynchronousHydration(attemptSynchronousHydration); + const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; let topLevelUpdateWarnings; diff --git a/packages/react-dom/src/events/ReactDOMEventReplaying.js b/packages/react-dom/src/events/ReactDOMEventReplaying.js index aa9e8270c452a..76ce3c7158232 100644 --- a/packages/react-dom/src/events/ReactDOMEventReplaying.js +++ b/packages/react-dom/src/events/ReactDOMEventReplaying.js @@ -20,7 +20,6 @@ import { unstable_scheduleCallback as scheduleCallback, unstable_NormalPriority as NormalPriority, } from 'scheduler'; -import {attemptSynchronousHydration} from 'react-reconciler/inline.dom'; import { attemptToDispatchEvent, trapEventForResponderEventSystem, @@ -32,6 +31,12 @@ import { import {getInstanceFromNode} from '../client/ReactDOMComponentTree'; import {unsafeCastDOMTopLevelTypeToString} from 'legacy-events/TopLevelEventTypes'; +let attemptSynchronousHydration: (fiber: Object) => void; + +export function setAttemptSynchronousHydration(fn: (fiber: Object) => void) { + attemptSynchronousHydration = fn; +} + // TODO: Upgrade this definition once we're on a newer version of Flow that // has this definition built-in. type PointerEvent = Event & {