Expo React Native 应用程序中对 Firestore 的持久性支持 [英] Persistence support for Firestore in Expo React Native app

查看:11
本文介绍了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 我找到的包.

Since Expo managed workflow does not support persistence, I'm using expo-firestore-offline-persistence package that I found.

如何获得 Firestore 的 non-memory-only 版本?

How do I get the non-memory-only build of Firestore?

推荐答案

版本 7.13.0:2020 年 3 月 26 日:

Memory-only Firestore was added in Version 7.13.0: March 26, 2020:

添加了仅内存的 Firestore 构建.它不是将数据保存在 IndexedDB 中,而是将其保存在内存中.此构建比全功能构建小约 14%,因为它没有与 IndexedDB 相关的代码.如果您不关心跨会话持久化数据,或者您的代码在不支持 IndexedDB 的环境中运行,请使用此构建来减小应用程序大小.它在特殊的导入路径下可用.你可以这样导入:

Added a memory-only firestore build. Instead of persisting data in the IndexedDB, it keeps it in memory. This build is about 14% smaller than the full featured build because it doesn't have IndexedDB related code. If you don't care about persisting data across sessions, or your code runs in environments that don't support IndexedDB, use this build to reduce your application size. It is available under a special import path. You can import it this way:

import * as firebase from 'firebase/app';
import 'firebase/firestore/memory';


// Don't change the format for any other products.
import 'firebase/auth';
// etc.

或者如果使用 CDN:

Or if using the 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. -->

这篇关于Expo React Native 应用程序中对 Firestore 的持久性支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆