How to use firebase account with expo

I followed Expo docs instructions , however I was not sure what was going on. I installed firebase using npm. Then the next step is to copy the firebase installation information that I did from the firebase console.

import * as firebase from 'firebase';

// Initialize Firebase
const firebaseConfig = {
  apiKey: "<YOUR-API-KEY>",
  authDomain: "<YOUR-AUTH-DOMAIN>",
  databaseURL: "<YOUR-DATABASE-URL>",
  storageBucket: "<YOUR-STORAGE-BUCKET>"
};

firebase.initializeApp(firebaseConfig);

But where does this world of code go? In root navigation or router? How can I refer to it in other parts of my application. As you can tell, I'm pretty new to Expo and React-Native, so your help is appreciated.

+4
source share
1 answer

main.js componentDidMount(). .

class App extends React.Component {
  componentDidMount() {
    const config = {
      apiKey: "<YOUR-API-KEY>",
      authDomain: "<YOUR-AUTH-DOMAIN>",
      databaseURL: "<YOUR-DATABASE-URL>",
      projectId: "<YOUR-PROJECT-ID>",
      storageBucket: "<YOUR-STORAGE-BUCKET>,
      messagingSenderId: "<YOUR-MESSAGING-SENDER-ID>"
    };
    firebase.initializeApp(config);
  }

  render() {
    return (
      <View >

      </View>
    );
  }
}

main.js, , firebase .

+2

Source: https://habr.com/ru/post/1681166/


All Articles