Aks*_*ain 12 javascript firebase react-native google-cloud-firestore react-native-firebase
我已经被这个问题困住了这么久。我刚刚开始使用 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)
任何帮助将非常感激!
发生此错误是因为缺少本机 RNFirestore 模块。
在yarn @react-native-firebase/firestore您需要运行pod install并触发重建之后react-native run-ios。
如果您有良好的 firebase / Firestore 设置,那么这是因为您的查询是错误的,您可以使用类似的内容进行测试:
import firestore from '@react-native-firebase/firestore';
firestore()
.collection('collection')
.onSnapshot((querySnapshot) => {
console.log(querySnapshot)
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2711 次 |
| 最近记录: |