Event API: responder event types should not re-register on EventComponent update (#15514)
Dominic Gannaway committed
Apr 26, 2019 at 21:33 UTC
796c67a25f980f1bcf9507b9f7d02131b8a2b552
2 files changed
+12
-9
packages/react-dom/src/client/ReactDOMHostConfig.js
+10
-9
@@ -894,20 +894,14 @@ export function didNotFindHydratableSuspenseInstance(
894
895
export function mountEventComponent(
896
eventComponentInstance: ReactEventComponentInstance,
897
-): void {
898
- if (enableEventAPI) {
899
- updateEventComponent(eventComponentInstance);
900
- mountEventResponder(eventComponentInstance);
901
- }
902
-}
903
-
904
-export function updateEventComponent(
905
- eventComponentInstance: ReactEventComponentInstance,
897
): void {
898
if (enableEventAPI) {
899
const rootContainerInstance = ((eventComponentInstance.rootInstance: any): Container);
900
const rootElement = rootContainerInstance.ownerDocument;
901
const responder = eventComponentInstance.responder;
902
+ if (__DEV__) {
903
+ Object.freeze(responder);
904
+ }
905
const {rootEventTypes, targetEventTypes} = responder;
906
if (targetEventTypes !== undefined) {
907
listenToEventResponderEventTypes(targetEventTypes, rootElement);
@@ -919,9 +913,16 @@ export function updateEventComponent(
913
);
914
listenToEventResponderEventTypes(rootEventTypes, rootElement);
915
}
916
+ mountEventResponder(eventComponentInstance);
917
}
918
}
919
920
+export function updateEventComponent(
921
+ eventComponentInstance: ReactEventComponentInstance,
922
+): void {
923
+ // NO-OP, why might use this in the future
924
+}
925
+
926
export function unmountEventComponent(
927
eventComponentInstance: ReactEventComponentInstance,
928
): void {
packages/react-dom/src/events/__tests__/DOMEventResponderSystem-test.internal.js
+2
@@ -886,5 +886,7 @@ describe('DOMEventResponderSystem', () => {
886
passiveSupported: true,
887
},
888
]);
889
+
890
+ ReactDOM.render(<Test />, container);
891
});
892
});