I am currently facing a problem with Firebase on my React Native app. Whenever I try to launch my app, I have the error:"TypeError: firebase.firestore is not a function."
I tried many solutions, like importing
var firebase = require("firebase/app")
require("firebase/firestore")
But it is not working. My firebase has the latest version.
Here is my code
import * as firebase from "firebase/app";
import "firebase/firestore";
import "firebase/storage";
// Initialize Firebase
firebaseConfig = {
...
};
var firebaseConfig = firebase.initializeApp(firebaseConfig);
export const st = firebase.storage();
const fr = firebase.firestore();
Do you guys have any solutions? Thanks in advance
try this, do not import all:
import firebase from 'firebase/app'
require('firebase/firestore')
require('firebase/storage')
// Initialize Firebase
firebaseConfig = {
...
};
var firebaseConfig = firebase.initializeApp(firebaseConfig);
export const st = firebase.storage();
const fr = firebase.firestore();
After a complete check of all my code, I realised that I also called firebase.firestore in another file. I didn't know that the error was there because the error was not specifying where the error was.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.