Search code examples
iosreact-nativerealmexpo

unknown execution context error - importing Realm to Expo React Native IOS app


I'm a beginner with RN, playing around with the expo tabs example and realmDB and Im getting unknown execution context error when importing Realm into Expo project and using the getting started example from Realm for IOS

enter image description here

I have followed the standard procedure from Realm docs

  1. npm install --save realm

  2. react-native link realm

but when i add const Realm = require('realm'); or import Realm from 'realm'; I get the error

You can see my code and project on github with the error throwing when I add the code to RNExpo/screens/SettingsScreen.js

What is causing this error? Am i meant to import Realm on other files apart from the file i am using realm in?


Solution

  • I managed to get in touch with Nikhilesh at Expo who told me that I was unable to use Expo with Realm because

    using Realm involves adding native code [and] to do something like that on expo you need to 'detach' which goes like this https://docs.expo.io/versions/v15.0.0/index.html

    He told me they Expo were interested in adding Realm support in the future, but for now it is not possible to use these services in unison.