Issue
This maybe a very novice question but I am stuck at here. I am a begineer in React-native and currently working with firebase real-time db with react. I've already initialized my firebase app in one screen(login.js). Since I am using firebase 3.X I cannot reinitialize that app again in another screen. How can I access that already initialized app into another screen(register.js)?
Solution
Here is how you export Firebase Config
Make sure you have added firebase to your project by npm install firebase --save
then create a config file at ./Config/FirebaseConfig.js
Add the below code in your file.
import Fb from 'firebase';
const config = {
apiKey: 'apiKey',
authDomain: 'projectId.firebaseapp.com',
databaseURL: 'https://databaseName.firebaseio.com',
};
const Firebase = Fb.initializeApp(config);
export default Firebase;
After this you can import firebase in any of your component by import Firebase from 'Firebase';
Answered By - user5714563
Answer Checked By - - Mary Flores (ReactFix Volunteer)