Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

'isomorphic-fetch' breaks react-native projects #22

Closed
alexfoxy opened this issue Mar 6, 2018 · 8 comments
Closed

'isomorphic-fetch' breaks react-native projects #22

alexfoxy opened this issue Mar 6, 2018 · 8 comments

Comments

@alexfoxy
Copy link

alexfoxy commented Mar 6, 2018

I can't use this api within a react native project as it conflicts with react natives own fetch.

To fix I have uncommented require('isomorphic-fetch'); from line 14 in RequestHandler.js

Is there a more solid fix?

@cosmocochrane1
Copy link
Contributor

@alexfoxy i'll check it out!

@giannif
Copy link
Collaborator

giannif commented May 31, 2018

@alexfoxy @cosmocochrane1
We do need some sort of polyfill if we're going to support older browsers that don't have fetch. Perhaps there's a way to not pollute the global scope.

There's this: https://www.npmjs.com/package/unfetch which is much smaller than the isomorphic-fetch lib I added way back when to support server side rendering, and it supports not polluting the global scope: https://www.npmjs.com/package/unfetch#usage

@rodrigobdz
Copy link
Contributor

@alexfoxy @giannif could you check if the approach in #26 works for you?

@rodrigobdz
Copy link
Contributor

I think this was fixed in #26. Close?

@cosmocochrane1
Copy link
Contributor

@rodrigobdz I'm gonna confirm - have you tried to run it with a reactnative proj yet?

@rodrigobdz
Copy link
Contributor

I am using the fix in a React Native project I am working on. I will create a new one to test in isolation.

Sent with GitHawk

@rodrigobdz
Copy link
Contributor

@cosmocochrane1 It's working for me. Feel free to try it out. I made a MCVE which you can find here.

There are two branches:

@cosmocochrane1
Copy link
Contributor

@rodrigobdz radddd thanks taking a look now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants