0

我有一个登录表单,在填写此表单时,我希望将值存储在数据库中,然后它应该导航到确认页面。问题是正在存储空白值

PS:导航在没有数据库插入功能的情况下可以正常传递值。

userLogin(email, password) {
  firebase.database().ref('users/').set({
    userEmail: email,
    userPass: password,
  }).catch((error)=>{
      console.log('error ' , error)
    });
}



           <Button
          title="Go to Details"
          onPress = {this.userLogin(this.state.email, this.state.password),
            this.props.navigation.navigate('Details', {
          email: this.state.email, 
          password: this.state.password,
          title: "Details Screen",
           })

          }
        />
4

1 回答 1

0
  1. 使用 Firebase 身份验证处理注册和登录流程,Firebase 将存储用户的身份验证详细信息。

userLogin = (email, password) =>{
        this.setState({
            loading:true
        })
        try {
            if(this.state.password.length >= 6){
                firebase.auth().signInWithEmailAndPassword(email,password).then(response =>{
                    this.props.navigation.navigate('Details');
                }).catch(error => {
                    alert("Email or password is incorrect");
                    this.setState({
                        loading: false
                    })
                })
            }else{
                alert("Password must be more than 6 characters")
                this.setState({
                    loading: false
                })
                return;
            }
        } catch (error) {
            console.log(error.toString())
        }
    }
    
    
    <Button title="Go to Details" onPress={()=>this. userLogin(this.state.email, this.state.password)} />

于 2019-05-14T08:46:01.840 回答