[英]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.