-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
self is not defined #125
Comments
just found https://github.com/matthew-andrews/isomorphic-fetch and then https://github.com/matthew-andrews/fetch/blob/master/fetch.js#L3 which has:
|
Yes please use that project instead. #31 |
I don't want to really use it in isomorphic way - I just have an isomorphic setup. That's a bit of a different thing. (Which is why those projects are not really what I am after) Ideally
Not nice - but works. |
Your workaround looks good. I would suggest applying the same conditional to all requires in your app that load libraries that are only useful in browsers. |
I will. As a side note - I would much prefer this style of use
or even better
Maybe for the next major version. |
Perhaps you're missing the point of this project. We're trying to create a polyfill for a future standard feature of browsers. The API for that feature is |
I see. |
Unfortunately in React Native, the workarounds mentioned don't seem to be sufficient. Due to the way React packages JS files assuming they support AMD/CommonJS modularization properly, this library ends up running anyway - even if it isn't required. |
@billinghamj We welcome a PR that solves this while keeping in mind that the code must also be able to run in a web worker environment. See #239 (comment) for context |
This was causing issues on projects targeting React Native, as the isomorphic-fetch polyfill did not support the correct lookup in the packager when determining what `fetch` module to use. See JakeChampion/fetch#125 (comment), matthew-andrews/isomorphic-fetch#63
React Native runs into an issue where self is undefined when using the global fetch method. (See JakeChampion/fetch#125). This typing definition allows the fix to be made.
Due to "self is not defined" JakeChampion/fetch#125 JakeChampion/fetch#657
I have an isomorphic react app. So while this the code is not running on node, still babel complains that "self is not defined". A quick hack that makes things work is to add "self = this;" to fetch.
Would be really nice to have a proper fix for this.
The text was updated successfully, but these errors were encountered: