-
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" error in React after upgrading to 3.0.0 #657
Comments
Hi could you tell us more about your module loader setup? Where does this happen, during compilation or execution in the browser? The more information the better, thank you! |
What is the solution? |
@davekedar Keep using 2.0.4 for now in your project. Isn't |
@mislav mine is a React project and not React Native. This error happens at build time. I assume i need this polyfill for plain React projects |
@mislav you are not getting the point, when we create the new project in Expo for react native it is fetching all the dependancies, thus this update is braking the initial loading. @karanmartian you can try restrict the version to 2.0.4 untill we get solution for this, it worked for me in react native |
I'm also seeing this exact error in our project which is a React project. |
ok, changing to the new |
@msafari Thank you for sharing! @karanmartian @davekedar How is |
yeah I also swapped to use the native one earlier and works fine on all browsers including IE11. The polyfill wasn't even needed for our case :D |
@msafari IE11 doesn't implement |
@mislav but that's exactly how we were using it that led to the react error mentioned in this issue with v3.0.0 |
@msafari Ah, I see. |
@mislav https://forums.expo.io/t/cant-find-variable-self/13547/9 please go through the link and you will find the problem and solution this is |
@AstRonin https://stackoverflow.com/questions/52269560/react-native-expo-cant-find-variable-self follow this question for the answer for the same, let me know if you can not solve it |
yes, on v.2.0.4 library works, but I need implementation of Fetch Abort in v.3.0.0, thats why I need new version |
Downgrading to v2.0.4 works. |
I'm confirming an issue in SSR React.js app with update to 3.0.0 from 2.0.4 |
The problem is in the umd build. You can see it here: https://unpkg.com/whatwg-fetch@3.0.0/dist/fetch.umd.js It references |
@wmertens |
in that case, webpack 4 is somehow not doing that |
Oh I misread that - the problem is happening on the Node side, somehow Node was running whatwg-fetch on the server during SSR :-/ I'll need to investigate why that's happening, but then it's not a |
Please do investigate, I'd be grateful! None of these reports sound like any of this is a whatwg-fetch issue. We built a polyfill for web browsers; our v3.0.0 works in every browser that we advertise supporting, as well as in service worker environment (that's why we use |
|
I must have been pulling in whatwg-fetch in node for a while now, and in
3.0 that started erroring? Not sure, in any case 3.0 works fine now, I
cleaned up my imports a bit.
Wout.
On Nov 29, 2018 3:51 PM, "hansnull" <notifications@github.com> wrote:
self might be undefined in unit tests.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#657 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AADWlrw0WZXsJ5diDXLfKYWIJsZSqpAvks5uz_RwgaJpZM4Wi73i>
.
|
To fix this, an easy solution would be to add a |
And rely on cross-fetch directly, as that version provides the desired interface. Due to "self is not defined" JakeChampion/fetch#657
Due to "self is not defined" JakeChampion/fetch#657
Due to "self is not defined" JakeChampion/fetch#125 JakeChampion/fetch#657
And rely on cross-fetch directly, as that version provides the desired interface. Due to "self is not defined" JakeChampion/fetch#657
Due to "self is not defined" JakeChampion/fetch#657
Using the temp fix suggested in the above comment by @idMolotov 's , fixed my issue (for now). Quoted temp fix below for convenience:
|
I used node-fetch currently at 2.6.0 to get around this, rather than fetch. |
This is also causing issues with server-side rendered Vue apps. I'm not calling fetch on the backend—I would not expect that to work—but in 1.x and 2.x it was possible to import the library. Now it errors on import on the server which means it isn't possible to use this library in server-side rendered apps in the same way. |
see JakeChampion/fetch#657 Signed-off-by: Patrick Ludewig <yes@patrick.works>
@kopax Your error says “Network request failed”, which leads me to believe it's a network-related runtime error and not a load error with this library, which this thread is all about. |
Fix for this will be #794 |
Hey Guys, please help after upgrading to latest version of whatwg-fetch I am seeing this error TypeError: Cannot use 'in' operator to search for 'URLSearchParams' in false |
Hi, I just upgraded, but seeing this issue. Any suggestions?
The text was updated successfully, but these errors were encountered: