I'm creating a react native project and using the firebase library. I import firebaseConfig from the firebase-config folder and initialize it to a constant, but an error occurs. What to do ? main file
import {
getAuth,
signInWithEmailAndPassword,
createUserWithEmailAndPassword,
} from 'firebase/auth';
import {initializeApp} from 'firebase/auth';
import {firebaseConfig} from '../firebase-config';
export default function Register() {
const [email, setEmail] = React.useState('');
const [password, setPassword] = React.useState('');
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const handleCreaceAccount = () => {
createUserWithEmailAndPassword(auth, email, password)
.then(() => {
console.log('CREATE !!!!!!!');
const user = userCredential.user;
console.log(user);
})
.catch(erorr => {
console.log(error);
});
};
firebase-config
export const firebaseConfig = {
apiKey: 'AIzaSyBk_dM7c2rw9VE7HRtfxG3cY97KG7wdFTM',
authDomain: 'zih-hal.firebaseapp.com',
projectId: 'zih-hal',
storageBucket: 'zih-hal.appspot.com',
messagingSenderId: '353959046913',
appId: '1:353959046913:web:2b6029d9ae04df5a32b500',
};
CodePudding user response:
You have a wrong import
. Convert
import {initializeApp} from 'firebase/auth';
to
import { initializeApp } from 'firebase/app';