Skip to content

Commit 796c67a

Browse files
authored
Event API: responder event types should not re-register on EventComponent update (#15514)
1 parent c4d1dcb commit 796c67a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -894,20 +894,14 @@ export function didNotFindHydratableSuspenseInstance(
894894

895895
export function mountEventComponent(
896896
eventComponentInstance: ReactEventComponentInstance,
897-
): void {
898-
if (enableEventAPI) {
899-
updateEventComponent(eventComponentInstance);
900-
mountEventResponder(eventComponentInstance);
901-
}
902-
}
903-
904-
export function updateEventComponent(
905-
eventComponentInstance: ReactEventComponentInstance,
906897
): void {
907898
if (enableEventAPI) {
908899
const rootContainerInstance = ((eventComponentInstance.rootInstance: any): Container);
909900
const rootElement = rootContainerInstance.ownerDocument;
910901
const responder = eventComponentInstance.responder;
902+
if (__DEV__) {
903+
Object.freeze(responder);
904+
}
911905
const {rootEventTypes, targetEventTypes} = responder;
912906
if (targetEventTypes !== undefined) {
913907
listenToEventResponderEventTypes(targetEventTypes, rootElement);
@@ -919,9 +913,16 @@ export function updateEventComponent(
919913
);
920914
listenToEventResponderEventTypes(rootEventTypes, rootElement);
921915
}
916+
mountEventResponder(eventComponentInstance);
922917
}
923918
}
924919

920+
export function updateEventComponent(
921+
eventComponentInstance: ReactEventComponentInstance,
922+
): void {
923+
// NO-OP, why might use this in the future
924+
}
925+
925926
export function unmountEventComponent(
926927
eventComponentInstance: ReactEventComponentInstance,
927928
): void {

packages/react-dom/src/events/__tests__/DOMEventResponderSystem-test.internal.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,5 +886,7 @@ describe('DOMEventResponderSystem', () => {
886886
passiveSupported: true,
887887
},
888888
]);
889+
890+
ReactDOM.render(<Test />, container);
889891
});
890892
});

0 commit comments

Comments
 (0)