【发布时间】:2022-06-15 17:35:51
【问题描述】:
当我启动应用程序并运行此功能时,尝试从 firebase 检索数据时遇到一些奇怪的行为:
const _query = query(_collection, where("userid", "==", uniqueUserID))
const querySnapshot = await getDocs(_query)
querySnapshot.forEach((doc) => {
console.log(doc.data())
});
我收到此错误:
Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to
the backend.
但是,如果我手动刷新应用程序并再次运行包含该函数的 useEffect,它会成功获取数据。考虑到这两个函数完全相同并且在加载或刷新视图时被调用,这很奇怪。我该如何解决这个问题?
注意:我使用的是 firebase 9.6.11 和 expo
【问题讨论】:
-
我有点面临同样的问题。看起来 UI 在 firebase 应用程序初始化之前加载。我正在关注 docs v9,它实际上是关于如何与 web 一起使用。所以我正准备尝试使用React Native Firebase 也许这会更好
标签: firebase react-native google-cloud-firestore