Issue
I realize that that there have already been several questions that address this kind of error, but none of them seem to provide the correct solution. I'm following Stephen Grider's React Native course on Udemy.
I'm pretty sure I've followed everything exactly, so I'm guessing the problem might have to do with an update to React or Firebase or something else, but I might be completely wrong. When pressing the button that activates the following code in onButtonPress():
state = { email: '', password: '', error: '' };
//a definition of the component's state, updated with onChangeText
onButtonPress() {
const { email, password } = this.state;
this.setState({ error: ' ' });
firebase.auth().signInWithEmailAndPassword(email, password) //this line is a "promise"
.catch(() => { //if it fails:
firebase.auth().creatUserWithEmailAndPassword(email, password) //also returns a promoise
.catch(() => { //if it also fails to create a username and password:
this.setState({ error: 'Authentication Failed.' });
});
});
}
I get the following error:
Since a lot of solutions on the web dealing with this error have to do with Firebase initialization, here's my code for that:
import React, { Component } from 'react';
import { View } from 'react-native';
import firebase from 'firebase';
import { Header } from './components/common/index.js'; //selects index.js automatically
import LoginForm from './components/LoginForm.js';
class App extends Component {
conponentWillMount() {
//called before render, will automatically be called because it's a life cycle method
firebase.initializeApp({
apiKey: '(I actually have my api key here, I just do not want people to steal it, same with the other values)',
authDomain: 'authenticationtutorial-ee660.firebaseapp.com',
databaseURL: 'my databaseURL',
projectId: 'my projectId',
storageBucket: 'authenticationtutorial-ee660.appspot.com',
messagingSenderId: 'my SenderId'
});
}
render() {
return (
<View>
<Header headerText="Authentication" />
<LoginForm />
</View>
);
}
}
export default App;
Any help would be appreciated. I've been dealing with this error for about a week now, and with no help on the Udemy website, I've turned to Stack Overflow :)
Solution
Correct the spelling of conponentWillMount
to componentWillMount
and correct the spelling of creatUserWithEmailAndPassword
to createUserWithEmailAndPassword
.
Thanks!
Answered By - Anson Savage
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.