I'm integrating Realm in my react native project and I get an error when I use the import statement defined on the realm documentation.
const Realm = require('realm');
I've followed all the steps on the web, but still getting the error. This is the output error from Xcode:
2018-05-31 11:11:53.037 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: undefined is not an object (evaluating 'self.fetch')
2018-05-31 11:11:53.036887+0200 wallet-development[1734:651340] Unhandled JS Exception: undefined is not an object (evaluating 'self.fetch')
2018-05-31 11:11:53.040 [warn][tid:com.facebook.react.JavaScript] Unable to symbolicate stack trace: Requiring module "fetch", which threw an exception: TypeError: undefined is not an object (evaluating 'self.fetch')
2018-05-31 11:11:53.040236+0200 wallet-development[1734:651343] Unable to symbolicate stack trace: Requiring module "fetch", which threw an exception: TypeError: undefined is not an object (evaluating 'self.fetch')
And this one what I get on the phone:

FYI: I could fix the issue by adding these lines just before importing the realm.
if (typeof global.self === 'undefined') {
global.self = global;
}
I found the possible fix here: https://github.com/facebook/react-native/issues/9599
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With