【发布时间】:2019-03-20 05:56:29
【问题描述】:
我需要有关此 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 它就可以正常工作。
为什么会出现这个错误?
【问题讨论】:
标签: javascript reactjs firebase-authentication runtime-error