I solved the issue this way :
let firebaseApp ;
if (!firebase.apps.length) {
firebaseApp = firebase.initializeApp(firebaseConfig);
}
else {
firebaseApp = firebase.app(); // if already initialized, use that one
}
export const auth = app.auth();
export default app;
The problem here is you are defining const app = ...
but it gets defined only for the if
scope ( it's how it works in js ). That's why initialize a variable using let
and then assign values to it
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…