I have a doubt, I don't know how I could export two components (if they are called like that) from firebase, in my case they are: auth and firestore,
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { getAuth } from "firebase/auth";
import { getFirestore } from "firebase/firestore";
const firebaseConfig = {
apiKey: "x-x",
authDomain: "x-x.x.x",
projectId: "x-x",
storageBucket: "x-x.x.x",
messagingSenderId: "x",
appId: "x",
measurementId: "x-x"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const db = getFirestore();
const analytics = getAnalytics(app);
const auth = getAuth(app);
export default {auth, db}
When I am working on another file and I want to import the component using:
import { db } from "firebase/firestore";
I get an error telling me the following:
I import it like this:
import {db} from "../firebase";
Thank you very much
You just have to replace
By
To import it you use this way
Firstly you have a wrong initialization, it must be
const db = getFirestore(app)
:now to import from another component assuming the initialization is done on the file
firebaseConfig.js
located in the directorysrc/firebase
: