In a React application, I usually initialize firebase like this:
if (firebase.apps.length < 1) {
  firebase.initializeApp(firebaseConfig);
  // Initialize other firebase products here
}
This worked perfectly until I upgraded to v9 beta. How do I make it work for the new version?
The correct way to do it is to use getApps():
import { getApps, initializeApp } from "firebase/app";
if (getApps().length < 1) {
  initializeApp(firebaseConfig);
  // Initialize other firebase products here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With