我正在尝试使用 createUserWithEmailAndPassword 构建身份验证。它不断抛出这个错误 firebase.auth 不是函数。 (在 'firebase.auth()' 中,'firebase.auth' 未定义
registerUser = () => {
if (this.state.email === '' && this.state.password === '') {
Alert.alert('Enter details to signup!');
} else {
this.setState({
isLoading: true,
});
firebase
.auth()
.createUserWithEmailAndPassword(this.state.email, this.state.password)
.then((res) => {
res.user.updateProfile({
displayName: this.state.displayName,
});
console.log('User registered successfully!');
this.setState({
isLoading: false,
displayName: '',
email: '',
password: '',
});
this.props.navigation.navigate('Login');
})
.catch((error) => this.setState({errorMessage: error.message}));
}
};