Home > Blockchain >  Is there any solution for "Firebase: Need to provide options, when not being deployed to hostin
Is there any solution for "Firebase: Need to provide options, when not being deployed to hostin

Time:12-08

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:

enter image description here

I wanted to make a function in my LogIn.js file like this:

enter image description here

handleRegister is the function that I use for onPress function of Register button

After all this I get the following:

enter image description here

enter image description here

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);
  • Related