最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - auth' is not exported from 'firebase' in react app - Stack Overflow

programmeradmin0浏览0评论

This is my first time using firebase in react and I get the error in a userProvider.js file

auth' is not exported from 'firebase'

while in my firebase.js I do

 import "firebase/auth";
 export const auth = firebase.auth();

and in my userProvider.js file I import it as

import {auth} from 'firebase';

I'm a plete beginner in this . I don't know if I'm missing something easy here

This is my first time using firebase in react and I get the error in a userProvider.js file

auth' is not exported from 'firebase'

while in my firebase.js I do

 import "firebase/auth";
 export const auth = firebase.auth();

and in my userProvider.js file I import it as

import {auth} from 'firebase';

I'm a plete beginner in this . I don't know if I'm missing something easy here

Share Improve this question edited Nov 7, 2020 at 15:30 Doug Stevenson 318k36 gold badges454 silver badges472 bronze badges asked Nov 7, 2020 at 13:44 vasilis 123vasilis 123 6752 gold badges15 silver badges31 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

You're not importing the Firebase SDKs correctly. Be sure to read the documentation on using Firebase with module bundlers. Starting with v8.0.0, you have to import Firebase SDKs like this:

import firebase from "firebase/app"
import "firebase/auth"

const auth = firebase.auth()

Do not import from "firebase" directly.

Firebase Authentication has a different import structure in version 9 To access the auth object, you should import it from 'firebase/auth' like this;

import { getAuth } from 'firebase/auth';
发布评论

评论列表(0)

  1. 暂无评论