Javascript Can';无法从React Native Firebase(v6)Firestore获取数据:undefined不是一个函数(接近';…此函数。_Firestore.Native.collectionGet…';)
我在这个问题上纠缠了这么久。我刚开始用react native firebase在我的react native应用程序中实现Firestore。我只是在看文档[但对我来说不起作用] 这是安卓系统。还没有在iOS上测试过 我不断地发现这个错误:Javascript Can';无法从React Native Firebase(v6)Firestore获取数据:undefined不是一个函数(接近';…此函数。_Firestore.Native.collectionGet…';),javascript,firebase,react-native,google-cloud-firestore,react-native-firebase,Javascript,Firebase,React Native,Google Cloud Firestore,React Native Firebase,我在这个问题上纠缠了这么久。我刚开始用react native firebase在我的react native应用程序中实现Firestore。我只是在看文档[但对我来说不起作用] 这是安卓系统。还没有在iOS上测试过 我不断地发现这个错误: [类型错误:未定义不是函数(靠近“…this.\u firestore.native.collectionGet…”)] 以下是相关代码: import React, {Component} from 'react'; import { firebase
[类型错误:未定义不是函数(靠近“…this.\u 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);
}
}
}
非常感谢您的帮助!如果您有一个良好的firebase/Firestore设置,那么这是因为您的查询是错误的,您可以使用以下内容进行测试:
import firestore from '@react-native-firebase/firestore';
firestore()
.collection('collection')
.onSnapshot((querySnapshot) => {
console.log(querySnapshot)
})
发生此错误是因为缺少本机RNFirestore模块
在
warn@react native firebase/firestore
之后,您需要运行pod安装
并使用react native run ios
触发重建,我收到了相同的错误。如果有任何帮助,我们将不胜感激。@BurningHippo,所以我刚刚卸载/重新安装了模块,再次执行了“react native run android”,现在它可以正常工作了。idk man lolI收到相同的错误。重新安装模块对我不起作用。