gpt4 book ai didi

javascript - 火力地堡 : Email has been badly formatted

转载 作者:行者123 更新时间:2023-11-30 14:10:53 24 4
gpt4 key购买 nike

我正在使用 react-native、formik 表单、yup 验证和 firebase 身份验证。但是,我在尝试登录时不断收到此错误:

createUser error: [Error: The email address is badly formatted.]

这是我的代码:火力地堡 API:

export const signInUser = (email, password) => {
console.log('signInUser has been called')
firebase.auth().signInWithEmailAndPassword(email.trim(), password)
.catch((error) => console.log('signIn error: ', error));
if (email==""){
console.log('email empty')
}
if (password==""){
console.log('password empty')
}
if (email=="abc@gmail.com"){
console.log('email not empty')
}

登录屏幕:

  createUser(){
FirebaseAPI.createUser(this.state.email, this.state.password)
}

signIn(){
FirebaseAPI.signInUser(this.state.email, this.state.password)
}

表格:

<Formik 
initialValues={{ email: '', password:'' }}
onSubmit={(values: FormValues, formikBag: FormikActions<FormValues>) =>
this.handleSubmit(values, formikBag)}
validationSchema= {yupObject().shape({
email: yupString()
.email("Inavlid email address")
.required("This field is required"),
password: yupString()
.min(8, "Password must be longer than 8 characters")
.required("This field is required")
})}
render={(formikBag: FormikProps<FormValues>) => this.renderForm(formikBag)}
/>

这是记录值后的结果:

[09:39:16] signInUser has been called
[09:39:16] email empty
[09:39:16] password empty
[09:39:16] signIn error: [Error: The email address is badly formatted.]

记录实际值不会给出任何结果,所以我选择检查字符串是否为空,看起来它们是。但是,当我删除 formik 表单并使用未经验证的常规输入字段时,一切正常。

最佳答案

在使用前验证 this.state.email。引用this对于类似的问题。

关于javascript - 火力地堡 : Email has been badly formatted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54496146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com