简体   繁体   English

"类型错误:_fire__WEBPACK_IMPORTED_MODULE_1__.default.auth 不是函数"

[英]TypeError: _fire__WEBPACK_IMPORTED_MODULE_1__.default.auth is not a function

I am a beginner at React.js.我是 React.js 的初学者。 I was following a tutorial to make a login authentication.我正在按照教程进行登录身份验证。 I am getting this error (TypeError: fire__WEBPACK_IMPORTED_MODULE_1<\/em> _.default.auth is not a function) from this part of the code: `我从这部分代码中收到此错误(TypeError: fire__WEBPACK_IMPORTED_MODULE_1<\/em> _.default.auth is not a function):`

const authListener = () => {
    fire.auth().onAuthStateChanged((user) => {
      if (user) {
        clearInputs();
        setUser(user);
      } else {
        setUser("");
      }
    })
  };

If you are using the Modular SDK v9.0.0<\/code> then try refactoring your code like this:如果您使用的是 Modular SDK v9.0.0<\/code> ,请尝试像这样重构您的代码:

import { initializeApp } from "firebase/app"
import { getAuth, onAuthStateChanged } from "firebase/auth"

const app = initializeApp(app)
const auth = getAuth(app)

const authListener = () => {
  onAuthStateChanged(auth, (user) => {
    if (user) {
      console.log(user)
    }
  })
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型错误:_fire__WEBPACK_IMPORTED_MODULE_11__.default.collection 不是 function - TypeError: _fire__WEBPACK_IMPORTED_MODULE_11__.default.collection is not a function 类型错误:_firebase_firebase__WEBPACK_IMPORTED_MODULE_8__.default.auth 不是 function - TypeError: _firebase_firebase__WEBPACK_IMPORTED_MODULE_8__.default.auth is not a function 如何修复此错误 TypeError: _components_firebase_Firebase__WEBPACK_IMPORTED_MODULE_2__.default.auth is not a function - How do I fix this error TypeError: _components_firebase_Firebase__WEBPACK_IMPORTED_MODULE_2__.default.auth is not a function 我一直遇到这个错误: Uncaught TypeError: firebase_compat_app__WEBPACK_IMPORTED_MODULE_0__.default.auth is not a function - I keep running into this error: Uncaught TypeError: firebase_compat_app__WEBPACK_IMPORTED_MODULE_0__.default.auth is not a function 未捕获的类型错误:_firebase__WEBPACK_IMPORTED_MODULE_0__.app.auth 不是 function - Uncaught TypeError: _firebase__WEBPACK_IMPORTED_MODULE_0__.app.auth is not a function TypeError:react__WEBPACK_IMPORTED_MODULE_6 ___ default.a.useState不是一个函数 - TypeError: react__WEBPACK_IMPORTED_MODULE_6___default.a.useState is not a function 类型错误:moment__WEBPACK_IMPORTED_MODULE_3___default(...)(...).calendar(...).sort 不是函数 - TypeError: moment__WEBPACK_IMPORTED_MODULE_3___default(...)(...).calendar(...).sort is not a function 类型错误:标记为__WEBPACK_IMPORTED_MODULE_3___default(...) 不是函数 - TypeError: marked__WEBPACK_IMPORTED_MODULE_3___default(...) is not a function 类型错误:_models_Products__WEBPACK_IMPORTED_MODULE_1__.default.find 不是函数 - TypeError: _models_Products__WEBPACK_IMPORTED_MODULE_1__.default.find is not a function 类型错误:_firebase__WEBPACK_IMPORTED_MODULE_9__.default.collection 不是 function - TypeError: _firebase__WEBPACK_IMPORTED_MODULE_9__.default.collection is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM