First of all, I have gone through my code and don't see anywhere where I might be initialising app more than once (unless I'm missing something).
I know this question has been asked and answered before but I'm not sure how to apply the solution to my own code as I'm just getting started with Firebase.
The error I'm getting is: Firebase App named '[DEFAULT]' already exists (app/duplicate-app).
Here is my config component:
export const DB_CONFIG = {
apiKey: "AIzaSyDj_UQoRkOWehv-Ox2IAphOQPqciE6jL6I",
authDomain: "react-notes-38f8a.firebaseapp.com",
databaseURL: "https://react-notes-38f8a.firebaseio.com",
projectId: "react-notes-38f8a",
storageBucket: "react-notes-38f8a.appspot.com",
messagingSenderId: "1063805843776"
};
Here is App.js
constructor(props){
super(props);
this.app = firebase.initializeApp(DB_CONFIG);
this.database = this.app.database().ref.child('notes')
this.state = {
notes: [
],
}
}
componentWillMount(){
const previousNotes = this.state.notes;
this.database.on('child_added', snap => {
previousNotes.push({
id: snap.key,
noteContent: snap.val().noteContent
})
})
this.setState({
notes: previousNotes
})
}