diff --git a/packages/react-dom/src/client/ReactDOMComponent.js b/packages/react-dom/src/client/ReactDOMComponent.js index d3ba6ae8ee3e7..bf5508c72cbb3 100644 --- a/packages/react-dom/src/client/ReactDOMComponent.js +++ b/packages/react-dom/src/client/ReactDOMComponent.js @@ -15,6 +15,7 @@ import {canUseDOM} from 'shared/ExecutionEnvironment'; import warningWithoutStack from 'shared/warningWithoutStack'; import type {ReactEventResponderEventType} from 'shared/ReactTypes'; import type {DOMTopLevelEventType} from 'events/TopLevelEventTypes'; +import {setListenToResponderEventTypes} from '../events/DOMEventResponderSystem'; import { getValueForAttribute, @@ -1337,3 +1338,8 @@ export function listenToEventResponderEventTypes( } } } + +// We can remove this once the event API is stable and out of a flag +if (enableEventAPI) { + setListenToResponderEventTypes(listenToEventResponderEventTypes); +} diff --git a/packages/react-dom/src/events/DOMEventResponderSystem.js b/packages/react-dom/src/events/DOMEventResponderSystem.js index 058d633fa0398..8ef3c42d55384 100644 --- a/packages/react-dom/src/events/DOMEventResponderSystem.js +++ b/packages/react-dom/src/events/DOMEventResponderSystem.js @@ -24,11 +24,18 @@ import {interactiveUpdates} from 'events/ReactGenericBatching'; import {executeDispatch} from 'events/EventPluginUtils'; import type {Fiber} from 'react-reconciler/src/ReactFiber'; -import {listenToEventResponderEventTypes} from '../client/ReactDOMComponent'; import {getClosestInstanceFromNode} from '../client/ReactDOMComponentTree'; import {enableEventAPI} from 'shared/ReactFeatureFlags'; +let listenToResponderEventTypesImpl; + +export function setListenToResponderEventTypes( + _listenToResponderEventTypesImpl: Function, +) { + listenToResponderEventTypesImpl = _listenToResponderEventTypesImpl; +} + const rootEventTypesToEventComponents: Map< DOMTopLevelEventType | string, Set, @@ -156,7 +163,7 @@ DOMEventResponderContext.prototype.addRootEventTypes = function( rootEventTypes: Array, ) { const element = this.eventTarget.ownerDocument; - listenToEventResponderEventTypes(rootEventTypes, element); + listenToResponderEventTypesImpl(rootEventTypes, element); const eventComponent = this._fiber; for (let i = 0; i < rootEventTypes.length; i++) { const rootEventType = rootEventTypes[i];