My goal is quite simple - I just want to retrieve data from Cloud Firestore.
Below is the code snippet I am using:
import React from 'react';
import firebase from "react-native-firebase";
export default class newsFeed extends React.Component {
constructor() {
this.ref = firebase.firestore().collection('keys')
}
async load(id) {
const doc = await this.ref.doc(id).get()
if (doc.exists) {
return doc.data()
}
}
}
However, I encounter an error: 'Cannot set property 'ref' of undefined'.
How can I troubleshoot this issue and what could be causing it?
For more information, I referred to this tutorial: https://medium.com/react-native-training/firebase-sdk-with-firestore-for-react-native-apps-in-2018-aa89a67d6934