小编Aks*_*ain的帖子

无法从 React-Native-Firebase(v6) Firestore 获取数据:undefined 不是函数(靠近 '...this._firestore.native.collectionGet...')

我已经被这个问题困住了这么久。我刚刚开始使用 react-native-firebase 在我的 react-native 应用程序中实现 Firestore。我只是在关注文档 [ https://invertase.io/oss/react-native-firebase/v6/firestore/quick-start#reading-data]但它对我不起作用。

这是在安卓中。尚未在 iOS 中测试。

我不断收到此错误:

[TypeError: undefined is not a function (near '...this._firestore.native.collectionGet...')]

这是相关的代码:

import React, {Component} from 'react';
import { firebase } from '@react-native-firebase/firestore';

export default App extends Component{
  constructor(props) {
    super(props);

    this.getData= this.getData.bind(this)
    this.getData()

    this.state = {};
  }

  async getData() {
    try {
      const querySnapshot = await firebase.firestore()
      .collection('Gyms')
      .get() //error with this

      console.log('Documents', querySnapshot.docs);

    } catch (e) {
      console.log(e);
    }
  }
}


Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激!

javascript firebase react-native google-cloud-firestore react-native-firebase

12
推荐指数
2
解决办法
2711
查看次数