我需要有关此 Google 身份验证功能的帮助……我在 firebase.js (React) 中有一个方法 doCreateUserWithEmail 和密码,如下所示。
doCreateUserWithEmailAndPassword = (email, password) => {
this.auth
.createUserWithEmailAndPassword(email, password)
.then(response => console.log(response))
.catch(err => console.log(err));};
当我将 then .then 和下面的内容附加到 signUp.js 时,就像这样......
onSubmitHandler = event => {
event.preventDefault();
const { email, passwordOne } = this.state;
this.props.firebase.doCreateUserWithEmailAndPassword(email, passwordOne)
.then(response => console.log(response))
.catch(err => console.log(err));
this.props.history.push(ROUTES.HOME);
};
我收到这个错误..
TypeError: Cannot read property 'then' of undefined
SignUpFormBase._this.onSubmitHandler
src/components/signUp/signUp.js:31
28 | onSubmitHandler = event => {
29 | event.preventDefault();
30 | const { email, passwordOne } = this.state;
> 31 | this.props.firebase.doCreateUserWithEmailAndPassword(email,
passwordOne)
| ^ 32 | .then(response => console.log(response))
33 | .catch(err => console.log(err));
34 | this.props.history.push(ROUTES.HOME);
View compiled
是的,当我收到错误消息时,我将它从 doCreateUserWithEmailAndPassword 中删除了..但该函数确实在 Firebase 中成功注册了用户,如果我拿走 .then 和 .catch 它工作正常。
为什么会出现此错误?