silentkiller
silentkiller

Reputation: 11

firebase__WEBPACK_IMPORTED_MODULE_1___default.a.firestore is not a function

I gets this error but when u hover mouse cursor on the .firestore() then in snippet it defines it as a function but on compilation/web it shows the following error. help me to solve it

 **firebase__WEBPACK_IMPORTED_MODULE_1___default.a.firestore is not a function** 
  
  
  
  3 | import 'firebase/firestore';
  4 | 
  5 | import { getFirestore } from "firebase/firestore"
> 6 | const firestore = firebase.firestore();
  7 | const firebaseConfig = {
  8 |     apiKey: "--------",
  9 |     authDomain: "--------",

Upvotes: 0

Views: 639

Answers (1)

Jay Lu
Jay Lu

Reputation: 1745

The method you use is before version 9, if your are useing firebase v9.x.x, the method changed.

Simple example :

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

const firebaseConfig = {
  apiKey: "xxxxx",
  authDomain: "xxxx",
  projectId: "xxxx",
  storageBucket: "xxxx",
  messagingSenderId: "xxxx",
  appId: "xxxxx",
  measurementId: "xxxxx"
};

const firebase = initializeApp(firebaseConfig);
const db = getFirestore();

export { firebase, db };

Upvotes: 1

Related Questions