Fix Firebase error on HMR with React
Posted on October 10, 2021
It's something annoying when developing a React App with Firebase as backend.
Every time you save, the HMR break the Firebase initialization, because Firebase is already initialized.
This is my quick solution:
if(!firebase.apps.length) firebase.initializeApp(config)
Basically, firebase.apps.length
is global and tells if there's any firebase app initialized.