mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Event API: responder event types should not re-register on EventComponent update (#15514)
This commit is contained in:
+10
-9
@@ -894,20 +894,14 @@ export function didNotFindHydratableSuspenseInstance(
|
||||
|
||||
export function mountEventComponent(
|
||||
eventComponentInstance: ReactEventComponentInstance,
|
||||
): void {
|
||||
if (enableEventAPI) {
|
||||
updateEventComponent(eventComponentInstance);
|
||||
mountEventResponder(eventComponentInstance);
|
||||
}
|
||||
}
|
||||
|
||||
export function updateEventComponent(
|
||||
eventComponentInstance: ReactEventComponentInstance,
|
||||
): void {
|
||||
if (enableEventAPI) {
|
||||
const rootContainerInstance = ((eventComponentInstance.rootInstance: any): Container);
|
||||
const rootElement = rootContainerInstance.ownerDocument;
|
||||
const responder = eventComponentInstance.responder;
|
||||
if (__DEV__) {
|
||||
Object.freeze(responder);
|
||||
}
|
||||
const {rootEventTypes, targetEventTypes} = responder;
|
||||
if (targetEventTypes !== undefined) {
|
||||
listenToEventResponderEventTypes(targetEventTypes, rootElement);
|
||||
@@ -919,9 +913,16 @@ export function updateEventComponent(
|
||||
);
|
||||
listenToEventResponderEventTypes(rootEventTypes, rootElement);
|
||||
}
|
||||
mountEventResponder(eventComponentInstance);
|
||||
}
|
||||
}
|
||||
|
||||
export function updateEventComponent(
|
||||
eventComponentInstance: ReactEventComponentInstance,
|
||||
): void {
|
||||
// NO-OP, why might use this in the future
|
||||
}
|
||||
|
||||
export function unmountEventComponent(
|
||||
eventComponentInstance: ReactEventComponentInstance,
|
||||
): void {
|
||||
|
||||
@@ -886,5 +886,7 @@ describe('DOMEventResponderSystem', () => {
|
||||
passiveSupported: true,
|
||||
},
|
||||
]);
|
||||
|
||||
ReactDOM.render(<Test />, container);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user