Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for React Native #23

Closed
kenfehling opened this issue Jun 28, 2015 · 6 comments
Closed

Workaround for React Native #23

kenfehling opened this issue Jun 28, 2015 · 6 comments

Comments

@kenfehling
Copy link

Hi, I'm using isomorphic-fetch in a shared library used by React and React Native. React Native provides its own fetch, so I'm currently using a workaround adapted from github/fetch#125.

if (typeof process !== 'undefined') {
    require('isomorphic-fetch');
}

Just wondering if something like this should be integrated into the isomorphic-fetch library. Thanks.

@matthew-andrews
Copy link
Owner

Thank you for your suggestion. I think your workaround seems neat enough for what is I imagine to be a fairly obscure use case so I would prefer not to put it into this library if possible. Sorry!

@thessem
Copy link

thessem commented Jun 26, 2016

@matthew-andrews would it be possible to take another look at this? I'm on react native and I'm using some libraries that pull in this one as a dependancy, I've had to shrinkwrap them so that they use #80 instead.

I understand it's unfair to expect you to support other people using your library badly, so I have no real expectations here, I just wanted to point out that perhaps the use case is slightly less obscure than you thought.

@julienvincent
Copy link

I understand it's unfair to expect you to support other people using your library badly

It's not so much the case of people using the library badly, but rather people being unaware that fetch will break react-native.

I think that this is an issue that should be fixed/handled here as the alternative is filing PR's for every library that depends on fetch in order to use within react-native.

@sosaucily
Copy link

@kenfehling I'm in the same boat, trying to use Redux-API-middlware with reactNative.

Can you elaborate a bit on how you were able to work around the problem? My app blows up when importing from redux-api-middleware. Thx

@thessem
Copy link

thessem commented Jul 28, 2016

@sosaucily Shrinkwrap the dependancy... read up on shrinkwrapping in npm, but the short version is you change the dependancy of redux-api-middleware in its package.json to point to #80 instead of this npm package (read up on using github branches as dependancies if you're not sure of the syntax), run npm install then npm shrinkwrap to make sure it sticks.

Caveat of my advice is I can't remember if this is exactly what I did, and my knowledge of npm is pretty rough

@wolframkriesing
Copy link

How I solved it (one of thousand solutions to this):
Problem was: a package I installed imported two node.js modules, one was import url from 'url'; the other was querystring and the third was isomorphic-fetch. The error message didn't really point me to those in the beginning.
I am now in the process of removing/replacing those dependencies.

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

No branches or pull requests

6 participants