React Firebase Integration - TypeError: firebase_app__WEBPAC



堆栈溢出!好久不见。

我正在开发一个web应用程序与反应,在那里你可以看到定义,我写在一个firebase数据库为现代概念,如打字怪癖和多元化。当尝试在我的应用程序中实现我的firebase firestore数据库时,它失败了,出现以下错误:

TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_0__.default is undefined.

以下是我在firebase.js中的代码:

import firebase from "firebase/compat/app";
import "firebase/compat/firestore";
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "dont-steal-my-db",

authDomain: "please-respond",

databaseURL: "https://definition-2d49c-default-rtdb.asia-southeast1.firebasedatabase.app",

projectId: "definition-2d49c",

storageBucket: "definition-2d49c.appspot.com",

messagingSenderId: "404265179808",

appId: "1:404265179808:web:10f7b7f917d695dabb87c5",

measurementId: "G-SYN64MDXL1"

};
firebase.initializeApp(firebaseConfig);
export default firebase;

我如何修复这个错误,哪里是一个好的地方去在未来与firebase类似的问题?

//try this :  
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
const firebaseConfig = {
apiKey: "dont-steal-my-db",
authDomain: "please-respond",
databaseURL: "https://definition-2d49c-default-rtdb.asia-southeast1.firebasedatabase.app",
projectId: "definition-2d49c",
storageBucket: "definition-2d49c.appspot.com",
messagingSenderId: "404265179808",
appId: "1:404265179808:web:10f7b7f917d695dabb87c5",
measurementId: "G-SYN64MDXL1"
};
const firebaseApp = firebase.initializeApp(firebaseConfig);
export const db = firebaseApp.firestore();

相关内容

  • 没有找到相关文章

最新更新