lquixada / cross-fetch

Universal WHATWG Fetch API for Node, Browsers and React Native.
MIT License
1.67k stars 104 forks source link

react-native already polyfills fetch #38

Closed msluther closed 5 years ago

msluther commented 5 years ago

react-native has built-in fetch polyfills based on whatwg-fetch already (https://github.com/facebook/react-native/blob/master/Libraries/Core/setUpXHR.js#L23-L26 some variant of this has existed over the last ~4 years or so from github history).

As such there's no real need to bundle in another fetch-ponyfill for react-native consumers. cross-fetch can simply re-export the existing fetch function (and related types).

There also exists some timing issue where the browser ponyfill is stomping the global fetch function with false here. The repro I've seen is in a decent sized app, while running in an iOS simulator and react-native@57. If I run the app, then start react-native JS debugging, this causes global.fetch to get set to false and never unset.

lquixada commented 5 years ago

Makes a lot of sense to me! Awesome idea!