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

Error Undefined is not an object (evaluating 'self.fetch') when importing Realm in React Native #22956

Closed
ataravati opened this issue Jan 11, 2019 · 6 comments
Labels
Bug 🌐Networking Related to a networking API. Resolution: Locked This issue was locked by the bot.

Comments

@ataravati
Copy link

ataravati commented Jan 11, 2019

Environment

React Native Environment Info:
System:
OS: macOS 10.14.2
CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
Memory: 1.47 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.14.1 - /usr/local/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 27
Build Tools: 27.0.3, 28.0.3
System Images: android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: 0.57.2 => 0.57.2
npmGlobalPackages:
react-native-cli: 2.0.1

Description

I get the following error message when importing Realm.

Undefined is not an object (evaluating 'self.fetch')

The issue has already been discussed here and here.

Reproducible Demo

I tried the solution provided in the other posts mentioned under Description, and the issue was resolved temporarily, until I added a reference to one of my mobx-state-tree stores. I did try the same solution in other screens, but that didn't help.

@react-native-bot react-native-bot added the 🌐Networking Related to a networking API. label Jan 11, 2019
@maxammann
Copy link

I can confirm this issue. This happens only in when "Debug JS Remotely" is turned off.

@akvsh-r
Copy link

akvsh-r commented Feb 8, 2019

This is likely an issue with the npm & builder cache. You must be having another dependency depending on whatwg-fetch.

Which you can easily check with npm ls whatwg-fetch.

Remove the dependency which is using whatwg-fetch reinstall it. Also clear the builder cache. If you're using expo expo start -c

You'll find some solution stating to do: global.self = global. Which is not really a solution.

@ataravati
Copy link
Author

ataravati commented Mar 14, 2019

@leaphawk The only dependency is fbjs which is part of react-native. I did manage to resolve the issue by using global.self = global, but as I added more screens to the application the issue came back.

@dulmandakh
Copy link
Contributor

Hello there 👋 this issue doesn't have a repro (which means, a react-native init-ed project with the minimal changes that leads to creating the same issue you are reporting). Unfortunately, I have no way of helping you in a meaningful way – there is no easy way for me to recreate the situation and check that the issue reported is still there when changing the code.

Because of this, we are going to close this issue - but if a repro is shared, we are happy to reopen it 🤗

@dulmandakh
Copy link
Contributor

Please upgrade to 0.59, and also provide reproducible demo.

@maxammann
Copy link

In my case this was caused by using the legacy babel plugin "transform-es2015-modules-commonjs".

maxammann added a commit to digitalfabrik/integreat-react-native-app that referenced this issue May 17, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Mar 19, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug 🌐Networking Related to a networking API. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants