TypeError: undefined is not an object (evaluating '_app.default.firestore')

I’m making a dating app using react native expo and firebase, it says TypeError: undefined is not an object (evaluating '_app.default.firestore') even though I have clearly imported firestore in my firebase config file:

// Import the functions you need from the SDKs you need
import firebase from 'firebase/app';
import 'firebase/firestore';
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { getAuth } from "firebase/auth"
import { getFirestore } from "firebase/firestore";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional

// Initialize Firebase
const app = initializeApp({
  apiKey: "",
  authDomain: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: "",
  appId: "",
  measurementId: ""
// const analytics = getAnalytics(app);
const auth = getAuth();
const db = getFirestore();
let firestore = firebase.firestore();

export { auth, db, firestore };

I know this is not a firebase forum but I already asked on the firebase GitHub forum and didn’t receive a reply, I was hoping someone here would know what to do.

I think, in the above snippet, you are exporting firestore directly. If you are using v9, this doesn’t seem the case anymore. The getFirestore() function initializes the Firestore service and gives you a reference so you can use in your app.

You will also need to pass the app reference since it contains the API keys. I’d suggest looking at initialization section in Firestore docs here. As per their docs, it’s:

import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";

// TODO: Replace the following with your app's Firebase project configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
    // ...

// Initialize Firebase
const app = initializeApp(firebaseConfig);

// Initialize Cloud Firestore and get a reference to the service
const db = getFirestore(app);

Are you using both Firebase JS SDK and React Native Firebase (RNFB) library?

If yes, I’d suggest sticking to one library. If you decide to use React Native Firebase library, remove Firebase JS SDK from your project, and check out their docs for more info on how to use the API: Cloud Firestore | React Native Firebase. Also see that RNFB has a different way to configure and setup: React Native Firebase | React Native Firebase