0

I am new to firebase, and I got this error. I am trying to make a signup page, but it is not working. What am I doing wrong? I removed some of the non-important parts from my code, but here is the part that the error occurs. My code:




export default class Signup extends Component {
  
  constructor() {
    super();
    this.state = { 
      displayName: '',
      email: '', 
      password: '',
      isLoading: false
    }
  }

  updateInputVal = (val, prop) => {
    const state = this.state;
    state[prop] = val;
    this.setState(state);
  }

  registerUser = () => {
    if(this.state.email === '' && this.state.password === '') {
      Alert.alert('Enter details to signup!')
    } else {
      this.setState({
        isLoading: true,
      })
      //firebase.default.auth()
      firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
      .then((res) => {
        res.user.updateProfile({
          displayName: this.state.displayName
        })
        console.log('User registered successfully!')
        this.setState({
          isLoading: false,
          displayName: '',
          email: '', 
          password: ''
        })
        this.props.navigation.navigate('Login')
      })
      .catch(error => this.setState({ errorMessage: error.message }))      
    }
  }

    
Phenomenon
  • 104
  • 7
  • Maybe it will help you https://stackoverflow.com/questions/48592656/firebase-auth-is-not-a-function – Dmitriy Zhiganov Jul 20 '21 at 18:04
  • Please share the complete code. When are you importing firbase? – Dharmaraj Jul 20 '21 at 18:18
  • @Dharmaraj I am importing from this file: import firebase from 'firebase/app' const firebaseConfig = { }; if (!firebase.apps.length) { firebase.initializeApp(firebaseConfig); } export default firebase; – Phenomenon Jul 20 '21 at 18:26

0 Answers0