电子邮件地址格式不正确Firebase / React-Native

时间:2019-05-09 17:59:06

标签: firebase react-native

当我放一些不同的字母(数字或符号)时,我收到此错误。 ................................................... ................................................... ................................................... ................................................... ................................................... ............................

这是我的代码:

export default class App extends React.Component {

  constructor (props) {
    super(props)

    this.state =({
      email:'',
      password:'',
    })
  }

  signUpUser = (email, password) => {

    try {

      if(this.state.password.length <6)
      {
        alert("Please enter atleast 6 characters")
        return;
      }

      firebase.auth().createUserWithEmailAndPassword(email, password)
    }

    catch (error){
      console.log(error.toString())
    }
  }

  loginUser =(email, password) => {

    try{

      firebase.auth().signInWithEmailAndPassword(email, password).then(function(user){
        console.log(user)
      })
    }

    catch (error) {
      console.log(error.toString())
    }
  }

  render() {
    return (
      <Container style={styles.container}>
        <Form>
          <Item floatingLabel>
            <Label> Email </Label>
            <Input
              autoCorrect={false}
              autoCapitalize='none'
              onChangeText={(email)=> this.setState({email})} 

              />
          </Item>

          <Item floatingLabel>
            <Label> Password </Label>
            <Input
              secureTextEntry={true}
              autoCorrect={false}
              autoCapitalize='none'
              onChangeText={(password)=> this.setState({password})}
              />
          </Item>

          <Button style={{marginTop: 10}}
          full
          rounded
          success
          onPress = {()=> this.loginUser(this.state.email,this.state.password)}
          >
            <Text> Login </Text>
          </Button>

          <Button style={{marginTop: 10}}
          full
          rounded
          primary
          onPress = {()=> this.signUpUser(this.state.email,this.state.password)}
          >
            <Text style={{color: 'white' }}> Sign Up </Text>
          </Button>
        </Form>
      </Container>
    );
  }
}

const styles = StyleSheet.create ({
  container:{
    flex: 1,
    backgroundColor: 'white',
    justifyContent: 'center',
    padding: 10
  }
}) 

enter image description here

0 个答案:

没有答案