错误:元素类型无效:预期字符串(用于内置组件)或类/函数(对于复合组件),但获取:未定义...

发布于 2025-01-24 02:52:59 字数 948 浏览 0 评论 0原文

import firebase from 'firebase/compat/app';
import "firebase/compat/storage";
import 'firebase/compat/auth';
import 'firebase/compat/firestore';

const firebaseConfig = {
  apiKey: "XXXX",
  authDomain: "YYYY.firebaseapp.com",
  projectId: "YYYY",
  storageBucket: "YYYY.appspot.com",
  messagingSenderId: "XXXX",
  appId: "XXXX",
};



const app = !firebase.apps.length
  ? firebase.initializeApp(firebaseConfig)
  : firebase.app();
  

const db = app.firestore();
const auth = app.auth();
const storage = firebase.storage();

export { auth, db, storage };
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
import firebase from 'firebase/compat/app';
import "firebase/compat/storage";
import 'firebase/compat/auth';
import 'firebase/compat/firestore';

const firebaseConfig = {
  apiKey: "XXXX",
  authDomain: "YYYY.firebaseapp.com",
  projectId: "YYYY",
  storageBucket: "YYYY.appspot.com",
  messagingSenderId: "XXXX",
  appId: "XXXX",
};



const app = !firebase.apps.length
  ? firebase.initializeApp(firebaseConfig)
  : firebase.app();
  

const db = app.firestore();
const auth = app.auth();
const storage = firebase.storage();

export { auth, db, storage };
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘然心甜 2025-01-31 02:52:59

这似乎是一个较旧版本的firebase,您应该与 firebase文档

也这对我有用:

import {
  GoogleAuthProvider,
  getAuth,
} from "firebase/auth";
import {
  getFirestore,
} from "firebase/firestore";

const firebaseConfig = {
    
  };

  const app = initializeApp(firebaseConfig);
  const auth = getAuth(app);
  const db = getFirestore(app);
  const googleProvider = new GoogleAuthProvider();
  
  export {auth , db, googleProvider};

That seems like an older version of firebase you should keep up to date with firebase documentation

Also this worked for me :

import {
  GoogleAuthProvider,
  getAuth,
} from "firebase/auth";
import {
  getFirestore,
} from "firebase/firestore";

const firebaseConfig = {
    
  };

  const app = initializeApp(firebaseConfig);
  const auth = getAuth(app);
  const db = getFirestore(app);
  const googleProvider = new GoogleAuthProvider();
  
  export {auth , db, googleProvider};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文