Firebase JavaScript SDK 和 react-native-firebase 有什么区别

What's the difference between Firebase JavaScript SDK and react-native-firebase

我正在尝试将 Firebase (Cloud Firestore) 用于反应本机应用程序,以存储我的 JSON 对象。

我看到有人在他们的 apps (npm install firebase) 中使用 Firebase,还有其他人使用 react-native-firebase。

大多数博客都说 Firebase 本身是为 web 设计的,所以他们的 react-native 支持是 none/less。而其他一些 blogs and firebase official blog 说 Firebase 支持 react-native。

我不确定为我的 react-native 项目选择哪个库,它们之间有什么区别。

根据project description on GitHub

React Native Firebase is a light-weight javascript layer connecting you to the native Firebase SDKs for both iOS and Android which aimes to mirror the offical Firebase Web SDK as closely as possible.

Although the official Firebase JS SDK will work with React Native; it is mainly built for the web and has a limited feature-set compared to native.

所以,你应该选择它,用于react native平台。这将允许您使用更多功能,并从使用本机 sdk 中获益(速度、内存消耗等)

从 Dima Rostopira 的回答中加起来。

使用expo需要在react native中使用JS SDK。 因为世博会不允许您添加自定义本机模块。 否则使用 React Native SDK

根据文档 https://docs.expo.dev/guides/using-firebase/#usage-with-expo

如果使用 expo,您仍然 可以使用 react-native-firebase 而不是 https://github.com/firebase/firebase-js-sdk,但需要插件