【问题标题】:Does Cloud Firestore support React NativeCloud Firestore 是否支持 React Native
【发布时间】:2018-03-17 18:37:16
【问题描述】:

我目前在我的 react-native 移动应用程序中使用 Firebase 实时数据库,并且我一直在寻找一些能够提供更好查询功能的替代方案。 Firestore 的优势之一是它的查询功能。我想检查一下 Firestore 是否支持开箱即用的 React Native。

【问题讨论】:

  • 您查看 Firestore 文档了吗?
  • 我做过,但没有明确提到它是否支持 React Native。
  • 你找到什么了吗?我正在寻找一种使用 mobx 和 firestore 制作原生应用程序的方法
  • 我按照接受的答案中的建议使用 react-native-firebase。
  • 你也可以使用firestore?一样吗?

标签: database firebase react-native google-cloud-firestore


【解决方案1】:

React Native Firebase 的 10 月 3 日版本包括 Cloud Firestore 支持。

首次支持新发布的 Cloud Firestore 测试版,请参阅 http://invertase.link/firestore 支持的 api。

import firebase from 'react-native-firebase';

firebase.firestore()
  .collection('posts')
  .add({
    title: 'Amazing post',
  })
  .then(() => {
    // Document added to collection and ID generated
    // Will have path: `posts/{generatedId}`
  })

【讨论】:

  • 感谢您的回复。我目前在我的 React Native 应用程序中使用 Firebase Web SDK,但我猜 Firestore 的 Web SDK 目前不支持 React Native。
【解决方案2】:

Cloud Firestore 支持此处列出的多个框架: https://firebase.google.com/docs/firestore/library-integrations

【讨论】:

    【解决方案3】:

    此外,您可以使用 Firestorter 之类的库将您的 Firestore 数据直接挂接到您的 React 组件:

    https://github.com/IjzerenHein/firestorter

    https://medium.com/@hrutjes/building-a-react-firestore-app-with-zero-effort-and-mobx-525df611eabf

    【讨论】:

      【解决方案4】:

      您也可以使用来自 invertase 的这个框​​架; https://rnfirebase.io/docs/v3.3.x/getting-started

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-11-10
        • 1970-01-01
        • 1970-01-01
        • 2018-09-19
        • 1970-01-01
        • 2020-08-09
        相关资源
        最近更新 更多