GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [react-events] Ensure we restore currentInstance + currentTimers (#16… · react/react@35a202d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-dom/src/events
    • DOMEventResponderSystem.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-dom/src/events/DOMEventResponderSystem.js‎

Copy file name to clipboardExpand all lines: packages/react-dom/src/events/DOMEventResponderSystem.js
+12-6Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ function processTimers(
360360
delay: number,
361361
): void {
362362
const timersArr = Array.from(timers.values());
363+
const previousInstance = currentInstance;
364+
const previousTimers = currentTimers;
363365
try {
364366
batchedEventUpdates(() => {
365367
for (let i = 0; i < timersArr.length; i++) {
@@ -374,8 +376,8 @@ function processTimers(
374376
}
375377
});
376378
} finally {
377-
currentTimers = null;
378-
currentInstance = null;
379+
currentTimers = previousTimers;
380+
currentInstance = previousInstance;
379381
currentTimeStamp = 0;
380382
}
381383
}
@@ -518,14 +520,16 @@ export function mountEventResponder(
518520
) {
519521
const onMount = responder.onMount;
520522
if (onMount !== null) {
523+
const previousInstance = currentInstance;
524+
const previousTimers = currentTimers;
521525
currentInstance = responderInstance;
522526
try {
523527
batchedEventUpdates(() => {
524528
onMount(eventResponderContext, props, state);
525529
});
526530
} finally {
527-
currentInstance = null;
528-
currentTimers = null;
531+
currentInstance = previousInstance;
532+
currentTimers = previousTimers;
529533
}
530534
}
531535
}
@@ -537,14 +541,16 @@ export function unmountEventResponder(
537541
const onUnmount = responder.onUnmount;
538542
if (onUnmount !== null) {
539543
let {props, state} = responderInstance;
544+
const previousInstance = currentInstance;
545+
const previousTimers = currentTimers;
540546
currentInstance = responderInstance;
541547
try {
542548
batchedEventUpdates(() => {
543549
onUnmount(eventResponderContext, props, state);
544550
});
545551
} finally {
546-
currentInstance = null;
547-
currentTimers = null;
552+
currentInstance = previousInstance;
553+
currentTimers = previousTimers;
548554
}
549555
}
550556
const rootEventTypesSet = responderInstance.rootEventTypes;

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.