Skip to content

Commit

Permalink
Event API: responder event types should not re-register on EventCompo…
Browse files Browse the repository at this point in the history
…nent update (#15514)
  • Loading branch information
trueadm authored Apr 26, 2019
1 parent c4d1dcb commit 796c67a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/react-dom/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,5 +886,7 @@ describe('DOMEventResponderSystem', () => {
passiveSupported: true,
},
]);

ReactDOM.render(<Test />, container);
});
});

0 comments on commit 796c67a

Please sign in to comment.