Home > Blockchain >  'Firebase' connection problem, Same code worked in 'react JS' but not worked in
'Firebase' connection problem, Same code worked in 'react JS' but not worked in

Time:11-17

firebase-config.js

import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
    apiKey: "**********************************",
    authDomain: "***********.firebaseapp.com",
    projectId: "***********",
    storageBucket: "***********.appspot.com",
    messagingSenderId: "*************",
    appId: "******************************",
    measurementId: "****************",
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);

const db = getFirestore(app);

export { db };

package.json

{
    "firebase": "^9.4.0", // latest version
}

It gives this error when running the app

ERROR [2021-11-16T08:33:02.823Z] @firebase/firestore: Firestore (9.4.0): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds. This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

How to solve this error?

CodePudding user response:

For react native.

Consider [https://rnfirebase.io/]. This will help you how to install Firebase in react native. As React Native is a cross platform and runs on native dom therefore you need to link the libraries and also add your bundle and package id in firebase console. Again DONT WORRY, this link will help you to do everything easily.

  • Related