Firebase 身份验证 ReferenceError:找不到变量:auth
2022-08-03
355
ReferenceError:找不到变量:auth
请帮忙
const handleLogin = () => {
auth
.signInWithEmailAndPassword(email, password)
.then(userCredentials => {
const user = userCredentials.user;
console.log('Logged in with:', user.email);
})
.catch(error => alert(error.message))
}
3个回答
从
npm install @react-native-firebase/auth
安装
@react-native-firebase/auth
并导入
从 '@react-native-firebase/auth' 导入 auth
Shivam
2022-08-04
安装 firebase/auth 包 并在使用它的组件中导入 auth 包 有关详细信息,请参阅此链接 https://rnfirebase.io/auth/usage
它应该是这样的
auth().signInWithEmailAndPassword(email, password)
Priyanka Chandak
2022-08-04
您期望
auth
来自何处?
如果您遵循 Firebase 文档,
入门
页面会将
auth
变量初始化为:
// Initialize Firebase Authentication and get a reference to the service
const auth = firebase.auth();
Frank van Puffelen
2022-08-03