Use globalThis if possible for native fetch in browser build (#22777)
This commit is contained in:
parent
afbc2d08f4
commit
520ffc77a3
|
@ -32,8 +32,11 @@ type RejectedRecord = {|
|
|||
|
||||
type Record = PendingRecord | ResolvedRecord | RejectedRecord;
|
||||
|
||||
declare var globalThis: any;
|
||||
|
||||
// TODO: this is a browser-only version. Add a separate Node entry point.
|
||||
const nativeFetch = window.fetch;
|
||||
const nativeFetch = (typeof globalThis !== 'undefined' ? globalThis : window)
|
||||
.fetch;
|
||||
|
||||
function getRecordMap(): Map<string, Record> {
|
||||
return unstable_getCacheForType(createRecordMap);
|
||||
|
|
|
@ -15,6 +15,7 @@ module.exports = {
|
|||
WeakSet: true,
|
||||
Uint16Array: true,
|
||||
Reflect: true,
|
||||
globalThis: true,
|
||||
// Vendor specific
|
||||
MSApp: true,
|
||||
__REACT_DEVTOOLS_GLOBAL_HOOK__: true,
|
||||
|
|
Loading…
Reference in New Issue