I have a problem using firebase with expo. I added the config and tried to add some content to Auth firebase.
I added my firebase.js file like this:
I wanted to make a function in my LogIn.js file like this:
handleRegister is the function that I use for onPress function of Register button
After all this I get the following:
CodePudding user response:
When you use getAuth()
directly in your components, there is no surety that Firebase was initialized in firebase.js
. Instead you should always ensure initializeApp()
is called before using any Firebase services. Here, you can import the auth
instance created in firebase.js
as shown below:
// firebase.js
const app = initializeApp(firebaseConfig);
// add export
export const auth = getAuth();
export const analytics = getAnalytics();
// Login.js
import { auth } from '../path/to/firebase.js' // <-- replace with correct path
// Remove the following
// const auth = getAuth();
// use imported 'auth'
createUserWithEmailAndPassword(auth, email, password);