Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28463

First argument "email" must be a valid string

$
0
0

I'm recently practicing React Native and developing a signup form attached to Firebase.

But whenever I tried to click the button, it gives an error:

createUserWithEmailAndPassword failed first argument email must be a valid string.

This is my code:

import React, {Component} from 'react';
import {
  SafeAreaView,
  StyleSheet,
  ScrollView,
  View,
  Text,
  StatusBar,
} from 'react-native';

import {Button,Input} from 'react-native-elements';
import firebase from './screens/firebase';

console.log(firebase.name);
console.log(firebase.database());

class App extends React.Component
{

constructor(props)
{
  super(props);
  this.state = {
    name:'',
    email : '',
    Password : '',
    tc:'',
    phone:'',
    };
}

handleRegisterUser = () => {
    const {name,email,Password,tc,phone} =this.setState;
    firebase.auth().createUserWithEmailAndPassword(email,Password)
    .then((user) => {
        const fbRootRefFS = firebase.firestore();
        const userID = user.uid;
        const userRef = fbRootRefFS.collection('users')
        .doc(userID);
        userRef.set({
            name,
            email,
            Password,
            tc,
            phone,
        });
    })
    }
  render(){
    return(
      <View style = {styles.container}>

      <Input
        placeholder='Enter Name'
        onChangeText={(name) => this.setState({name})}/>

      <Input
        placeholder='Enter Email'
        onChangeText={(email) => this.setState({email})}/>

      <Input
        placeholder='Enter Password'
        onChangeText={(Password) => this.setState({Password})}/>

       <Input
        placeholder='Enter TC'
        onChangeText={(tc) => this.setState({tc})}/>

        <Input
         placeholder='Enter Phone'
         onChangeText={(phone) => this.setState({phone})}/>

    <View style={{marginTop : 40,flexDirection : 'row'}}>

     <Button
       title="Sign UP"
       onPress = {() => this.handleRegisterUser(this.state.name,this.state.email,this.state.Password,this.state.tc,this.state.phone)}/>
      </View>
     </View>
      );
  }
}

const styles = StyleSheet.create({
  container :
  {
    flex : 1,
    justifyContent : 'center',
    alignItems : 'center',
  }
});

export default App;

Where am I making a mistake? I have been dealing with this problem for a long time, thanks for your help.


Viewing all articles
Browse latest Browse all 28463

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>