I am getting this error in my react-native expo project: FirebaseError: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app). I have cross checked my project and I have not imported firebase anywhere else in the project. I have also made a firebase.js file and initialised the firebase config there. Here is my code:
This is my firebase.js file
import firebase from "firebase";
const firebaseConfig = {
apiKey: "XXXXXXXXXXXX",
authDomain: "XXXXXXXXXXXX",
databaseURL: "XXXXXXXXXXXX",
projectId: "XXXXXXXXXXXX",
storageBucket: "XXXXXXXXXXXX",
messagingSenderId: "XXXXXXXXXXXX",
appId: "XXXXXXXXXXXX",
};
const Firebase = firebase.initializeApp(firebaseConfig);
export default Firebase;
This is the Signin.js file where I want to use firebase.
import { StatusBar } from "expo-status-bar";
import React, { useState } from "react";
import {
StyleSheet,
Text,
View,
TextInput,
TouchableOpacity,
Picker,
ScrollView,
} from "react-native";
import { FontAwesome } from "@expo/vector-icons";
import { LinearGradient } from "expo-linear-gradient";
import firebase from "./firebase";
import "firebase/auth";
function Signin() {
firebase
.auth()
.signInWithEmailAndPassword("[email protected]", "bhavansh")
.catch(function (error) {});
}
export default function LogIn({ navigation }) {
const [selectedValue, setSelectedValue] = useState("java");
return (
<View style={styles.container}>
<View style={styles.header}>
<Text style={styles.header_text}>Register</Text>
</View>
<View style={styles.footer}>
<ScrollView
showsVerticalScrollIndicator={false}
style={styles.ScrollView}
show
>
<Text style={styles.fields}>Name</Text>
<TextInput
placeholder="Enter your Name"
style={styles.input}
></TextInput>
<Text style={styles.fields}>Email</Text>
<TextInput placeholder="Enter Email" style={styles.input}></TextInput>
<Text style={styles.fields}>Password</Text>
<TextInput placeholder="Enter Password" style={styles.input} />
<Text style={styles.fields}>Confirm Password</Text>
<TextInput
placeholder="Enter Confirm Password"
style={styles.input}
/>
<View style={styles.picker}>
<TouchableOpacity style={styles.position}>
<LinearGradient
colors={["#08d4c4", "#01ab9d"]}
style={styles.picker_gradient}
>
<Text style={styles.button_text}>Passenger</Text>
</LinearGradient>
</TouchableOpacity>
<TouchableOpacity
style={styles.position}
onPress={() => navigation.navigate("SignIn")}
>
<Text style={styles.sign_button_text}>Rider</Text>
</TouchableOpacity>
</View>
<TouchableOpacity style={styles.button} onPress={() => Signin()}>
<LinearGradient
colors={["#08d4c4", "#01ab9d"]}
style={styles.gradient_style}
>
<Text style={styles.button_text}>Register</Text>
</LinearGradient>
</TouchableOpacity>
<TouchableOpacity
style={styles.sign_button}
onPress={() => navigation.navigate("LogIn")}
>
<Text style={styles.sign_button_text}>Log In</Text>
</TouchableOpacity>
</ScrollView>
</View>
</View>
);
}