Using firebase emulator with react-fire package

108 Views Asked by At

I am, following this answer, setting up the firebase emulator using react-fire with the following code

const preloadSDKs = (firebaseApp: firebase.app.App) => {
    return Promise.all([
        preloadFirestore({
            firebaseApp,
            setup: firestore => {

                return firestore().useEmulator('localhost', 8080);
            }
        }),
    ]);
};

interface IAppProps {
}

const App: React.FunctionComponent<IAppProps> = (props) => {

    const firebaseApp = useFirebaseApp();



    preloadSDKs(firebaseApp).then(() => Promise.resolve());

However, I am a bit confused as to how I can add some condidtional code that makes sure I use the emulator in development, and use my cloud firestore in production build.

Can anyone help me configure this?

0

There are 0 best solutions below