firebase - Expo React Native 应用程序中对 Firestore 的持久性支持
问题描述
我收到以下错误:
You are using the memory-only build of Firestore. \
Persistence support is only available via the @firebase/firestore bundle \
or the firebase-firestore.js build.
我正在使用以下导入
import "expo-firestore-offline-persistence";
import firebase from "firebase";
import "firebase/firestore";
由于 Expo 托管工作流不支持持久性,因此我使用expo-firestore-offline-persistence
的是我找到的包。
如何获得non-memory-only
Firestore 的构建版本?
解决方案
仅内存 Firestore 已在7.13.0 版中添加:2020 年 3 月 26 日:
添加了仅内存的 Firestore 构建。它不是将数据保存在 IndexedDB 中,而是将其保存在内存中。此构建比全功能构建小约 14%,因为它没有与 IndexedDB 相关的代码。如果您不关心跨会话持久化数据,或者您的代码在不支持 IndexedDB 的环境中运行,请使用此构建来减小应用程序大小。它在特殊的导入路径下可用。您可以通过以下方式导入它:
import * as firebase from 'firebase/app';
import 'firebase/firestore/memory';
// Don't change the format for any other products.
import 'firebase/auth';
// etc.
或者如果使用 CDN:
<script src="https://www.gstatic.com/firebasejs/7.13.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.13.0/firebase-firestore.memory.js"></script>
<!-- Don't change the format for any other products. -->
<script src="https://www.gstatic.com/firebasejs/7.13.0/firebase-auth.js"></script>
<!-- etc. -->
推荐阅读
- mysql - #1054 更新 mysql 时出错
- c# - 将嵌套的复杂类型发布到 .net core 2.0 api
- tensorflow - 如何在 tensorflow 会话中将图像 url 传递给 feed_dict?
- automation - 我们可以自动化 ESRI windows 应用程序映射吗
- java - Struts2 Locale(I18N) 不适用于印度语言“泰米尔语”
- apache-kafka - Kafka表中聚合记录的超时?
- javascript - 从 Messagebox 内的同一控制器访问函数名称
- javascript - 关于增量反角js,减量计数器没有按预期工作
- qt - Qt 中的 SPI 和 I2C 协议检测
- reactjs - 我可以给 Ant Design Icon 一个自定义 URL 吗?