Skip to content

Commit e9b857b

Browse files
rickhanloniizhengjitf
authored andcommitted
Cache local reference to global Promise (facebook#21886)
1 parent 0b3cfd3 commit e9b857b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ export const scheduleTimeout: any =
392392
export const cancelTimeout: any =
393393
typeof clearTimeout === 'function' ? clearTimeout : (undefined: any);
394394
export const noTimeout = -1;
395+
const localPromise = Promise;
395396

396397
// -------------------
397398
// Microtasks
@@ -400,9 +401,10 @@ export const supportsMicrotasks = true;
400401
export const scheduleMicrotask: any =
401402
typeof queueMicrotask === 'function'
402403
? queueMicrotask
403-
: typeof Promise !== 'undefined'
404+
: typeof localPromise !== 'undefined'
404405
? callback =>
405-
Promise.resolve(null)
406+
localPromise
407+
.resolve(null)
406408
.then(callback)
407409
.catch(handleErrorInNextTick)
408410
: scheduleTimeout; // TODO: Determine the best fallback here.

0 commit comments

Comments
 (0)