Skip to content

Commit

Permalink
[react-events] Ensure we restore currentInstance + currentTimers (#16758
Browse files Browse the repository at this point in the history
)
  • Loading branch information
trueadm authored Sep 12, 2019
1 parent 3717c25 commit 35a202d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/react-dom/src/events/DOMEventResponderSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ function processTimers(
delay: number,
): void {
const timersArr = Array.from(timers.values());
const previousInstance = currentInstance;
const previousTimers = currentTimers;
try {
batchedEventUpdates(() => {
for (let i = 0; i < timersArr.length; i++) {
Expand All @@ -374,8 +376,8 @@ function processTimers(
}
});
} finally {
currentTimers = null;
currentInstance = null;
currentTimers = previousTimers;
currentInstance = previousInstance;
currentTimeStamp = 0;
}
}
Expand Down Expand Up @@ -518,14 +520,16 @@ export function mountEventResponder(
) {
const onMount = responder.onMount;
if (onMount !== null) {
const previousInstance = currentInstance;
const previousTimers = currentTimers;
currentInstance = responderInstance;
try {
batchedEventUpdates(() => {
onMount(eventResponderContext, props, state);
});
} finally {
currentInstance = null;
currentTimers = null;
currentInstance = previousInstance;
currentTimers = previousTimers;
}
}
}
Expand All @@ -537,14 +541,16 @@ export function unmountEventResponder(
const onUnmount = responder.onUnmount;
if (onUnmount !== null) {
let {props, state} = responderInstance;
const previousInstance = currentInstance;
const previousTimers = currentTimers;
currentInstance = responderInstance;
try {
batchedEventUpdates(() => {
onUnmount(eventResponderContext, props, state);
});
} finally {
currentInstance = null;
currentTimers = null;
currentInstance = previousInstance;
currentTimers = previousTimers;
}
}
const rootEventTypesSet = responderInstance.rootEventTypes;
Expand Down

0 comments on commit 35a202d

Please sign in to comment.