I am trying to use Firebase in an app component. This is how the code looks like for that component (removed the api details from json while posting here).
import React from "react";
import * as firebase from "firebase";
const New_meet =() =>{
var firebaseConfig={
apiKey: ,
authDomain: ,
databaseURL: ,
projectId: ,
storageBucket: ,
messagingSenderId: ,
appId: ,
measurementId:
};
console.log("here");
firebase.initializeApp(firebaseConfig);
const preObject = document.getElementById('object');
const dbRefObject = firebase.database().ref().child('object');
dbRefObject.on('value',snap=>console.log(snap.val()));
return(
<div>
<p id="object"></p>
</div>
);
}
export default New_meet;
The problem is, when I insert that firebaseInitializeApp function(already present for now), it gives the error
"Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app)."
And when I remove that line, it shows
"Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)"
I am not importing firebase in App.js or any other components. Have never used Firebase before so no clue how to tackle this.