简体   繁体   English

类型错误:调用“firebase.auth().onAuthStateChanged((user)”时无法读取未定义的属性“auth”

[英]TypeError: Cannot read property 'auth' of undefined when calling " firebase.auth().onAuthStateChanged((user)"

i am new to using react native and firebase, I have this error: "TypeError: Cannot read property 'auth' of undefined"我是使用 react native 和 firebase 的新手,我有这个错误:“TypeError:无法读取未定义的属性‘auth’”

I proceed to attach my code in an image:我继续在图像中附加我的代码:

在此处输入图片说明

I also proceed to copy and paste dependencies:我还继续复制和粘贴依赖项:

    "dependencies": {

"@react-native-community/masked-view": "0.1.10", "@react-native-community/masked-view": "0.1.10",

"@react-navigation/bottom-tabs": "~5.2.6", "@react-navigation/bottom-tabs": "~5.2.6",

"@react-navigation/native": "~5.1.5", "@react-navigation/native": "~5.1.5",

"@react-navigation/stack": "~5.2.10", "@react-navigation/stack": "~5.2.10",

"expo": "~42.0.1", “博览会”:“~42.0.1”,

"expo-status-bar": "~1.0.4", "expo-status-bar": "~1.0.4",

"firebase": "^9.1.2", "firebase": "^9.1.2",

"react": "16.13.1", “反应”:“16.13.1”,

"react-dom": "16.13.1", "react-dom": "16.13.1",

"react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz", "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",

"react-native-elements": "^3.4.2", “反应原生元素”:“^ 3.4.2”,

"react-native-gesture-handler": "~1.10.2", "react-native-gesture-handler": "~1.10.2",

"react-native-reanimated": "~2.2.0", "react-native-reanimated": "~2.2.0",

"react-native-router-flux": "3.36.0", "react-native-router-flux": "3.36.0",

"react-native-safe-area-context": "^3.3.2", "react-native-safe-area-context": "^3.3.2",

"react-native-screens": "~3.4.0", "react-native-screens": "~3.4.0",

"react-native-vector-icons": "^8.1.0", "react-native-vector-icons": "^8.1.0",

"react-native-web": "~0.13.12" “react-native-web”:“~0.13.12”

}, },

You are using Firebase Modular SDK which has a completely new syntax and you also need to import Firebase Auth.您正在使用具有全新语法的 Firebase Modular SDK,您还需要导入 Firebase Auth。 To keep using existing code you can try changing the imports to these:要继续使用现有代码,您可以尝试将导入更改为:

import firebase from 'firebaser/compat/app'
import 'firebase/compat/auth'

I'll recommend upgrading to Modular SDK for it's benefits and the compat version will be removed soon.我建议升级到 Modular SDK以获得好处,并且很快就会删除兼容版本。

暂无
暂无

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

相关问题 调用firebase.auth()。onAuthStateChanged()时出现“ Uncaught TypeError:无法读取未定义的属性'resolve'” - “Uncaught TypeError: Cannot read property 'resolve' of undefined” when calling firebase.auth().onAuthStateChanged() "firebase.auth().onAuthStateChanged 不工作" - firebase.auth().onAuthStateChanged Not Working Firebase 和 React TypeError: firebase.auth(...).onAuthStateChanged 不是 function - Firebase and React TypeError: firebase.auth(...).onAuthStateChanged is not a function 跨两个页面使用 firebase.auth().onAuthStateChanged 时的问题 - Issue when using firebase.auth().onAuthStateChanged accross two pages 刷新页面时,有时firebase.auth()。onAuthStateChanged返回null的用户 - Sometimes firebase.auth().onAuthStateChanged returns user of null when I refresh the page 在 React 中放置 firebase.auth().onAuthStateChanged 的位置 - where to place firebase.auth().onAuthStateChanged in React firebase.auth().onAuthStateChanged 无限循环 - firebase.auth().onAuthStateChanged looping infinitely firebase onAuth()抛出:TypeError无法读取未定义的属性'auth' - firebase onAuth() throwing: TypeError cannot read property 'auth' of undefined TypeError:无法读取未定义Vuejs的属性'$ auth' - TypeError: Cannot read property '$auth' of undefined Vuejs Firebase:如何从 firebase.auth().onAuthStateChanged 异步绑定用户到 Angular 模板? - Firebase: How to asynchronously bind User from firebase.auth().onAuthStateChanged to Angular template?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM