【发布时间】:2021-09-16 10:31:21
【问题描述】:
我使用以下文章设置了我的 react-native 应用并连接到 firebase:https://firebase.googleblog.com/2016/01/the-beginners-guide-to-react-native-and_84.html。
我想通过在模拟器中运行 firebase 服务来测试我的更改。谁能指导我怎么做?
--编辑--
我按照https://firebase.google.com/docs/emulator-suite/connect_and_prototype 中列出的步骤,在 config.js 文件中添加了以下 sn-p:
var db = firebase.firestore();
if (location.hostname === "localhost") {
db.useEmulator("localhost", 8080);
}
执行应用程序后,我得到以下错误:
ReferenceError: Can't find variable: location
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue
Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue
【问题讨论】:
-
您尝试过什么了吗?如果你这样做了,请编辑你的问题以显示你卡在哪里。如果没有,这将是一个很好的起点:firebase.google.com/docs/emulator-suite/connect_and_prototype
-
@FrankvanPuffelen 我已经编辑了问题。
标签: firebase react-native firebase-authentication