0

I am trying to connect my app with firbase using firebase.initializeApp but it is keep giving me an error that TypeError: firebase.initializeApp is not a function. (In 'firebase.initializeApp(_config.firebaseConfig)', 'firebase.initializeApp' is undefined. I tried to search answers on stackoverflow but most of the correct answers is around importing right library or correcting typo in the code.

I am very sure that I am importing the right library and using firebase.initializeApp in correct order. But, I am still getting same error. Can any one help?

Please note (not sure it is important) - This all started when I start implementing redux in my app

Below is my code:

config.js

export const firebaseConfig = {
  apiKey: "**********",
  authDomain: "**********",
  databaseURL: "**********",
  projectId: "**********",
  storageBucket: "**********",
  messagingSenderId: "**********",
  appId: "**********",
  measurementId: "**********",
};

app.js - This where I need to call funtion firebase.initializeApp fuction to connect my app with firebase.

import * as firebase from "firebase/app";
import { firebaseConfig } from "./config/config";
import "firebase/auth";
import "firebase/firestore";


class App extends React.Component {
  constructor() {
    super();
    this.initializeFirebaase();
  }

  initializeFirebaase = () => {
    firebase.initializeApp(firebaseConfig);
  };

  render() {
    return (
      <Provider store={store}>
        <AppContainer />
      </Provider>
    );
  }
}

1 Answers1

0

Can you try import * as firebase from "firebase"; --> remove "/app"

  • 2
    You are asking a question, a rhetoric one though. You are proposing to try something. You do not explain how this helps or why it works. Please do not be surprised if the number of people finding this "useful" (as is required for an upvote) is low. Have a look at [answer], and (since you did not bother yet) take the [tour]. – Yunnosch Mar 08 '21 at 20:09