未知执行上下文错误 - 将 Realm 导入 Expo React Native IOS 应用程序

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

我是 RN 的初学者,玩过 expo 选项卡示例和 realmDB,在将 Realm 导入 Expo 项目并使用 getting started example 来自领域 IOS

我遵循了 Realm 文档中的标准程序

  1. npm install --save realm

  2. react-native link realm

但是当我添加 const Realm = require('realm');import Realm from 'realm'; 时出现错误

您可以在 github 上看到我的代码和项目,当我将代码添加到 RNExpo/screens/SettingsScreen.js

时抛出错误

导致此错误的原因是什么?除了我在其中使用领域的文件之外,我是否打算在其他文件上导入领域?

我设法与 Expo 的 Nikhilesh 取得联系,他告诉我我无法将 Expo 与 Realm 一起使用,因为

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

他告诉我他们 Expo 有兴趣在未来添加 Realm 支持,但现在不可能同时使用这些服务。