firebase: firebase app named '[default]' already exists (app/duplicate-app) in react code example
Example 1: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app).
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
Example 2: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app).
import * as firebase from "firebase";
const config = {...};
export default !firebase.apps.length ? firebase.initializeApp(config) : firebase.app();
import firebase from '../firebase';
...
console.log(firebase.name);