I'm trying to make use of the modular firebase version, which is v9 and above if I'm not mistaken.
I'm building a react native app, I can successfully make use of the auth service, but when I try using the firestore, I get an error. I watched a video and followed his approach, of which he used the firebase npm package to install his, here's a link to it: https://www.npmjs.com/package/firebase
Something to note here is that I've already set up my firebase project and followed the instruction in integrating it into my app, and I downloaded the google service json file needed. But now I have trouble trying to initialize my app, and start making use of the modular approach. This wasn't the issue while I was developing my previous test app; although v9 wasn't released then, so I wasn't using modular approach.
I'm thinking if it's from the module I'm doing the imports from (but I'm not sure), it'd be nice if someone can walk me through this. I'll never forget again, I promise.
//THE ERROR IS GET
ERROR FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
//the way i'm using/calling firebase
import firebase from 'firebase/app';
import {getFirestore, collection, getDocs} from 'firebase/firestore/lite';
firebase.initializeApp();
const Home = () => {
const database = getFirestore();
const colRef = collection(database, 'users');
//...other codes
}
//MY DEPENDENCIES
"dependencies": {
"@react-native-firebase/app": "^14.5.1",
"@react-native-firebase/auth": "^14.5.1",
"@react-native-firebase/storage": "^14.5.1",
"firebase": "^9.6.7",
//...other dependencies
}