i'm trying to connect the DB to my App.js, it works, but when i try to do the auth, this error come out:
Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.app(). Ensure you have:
- imported the 'io.invertase.firebase.app.ReactNativeFirebaseAppPackage' module in your 'MainApplication.java' file.
- Added the 'new ReactNativeFirebaseAppPackage()' line inside of the RN 'getPackages()' method list.
This is my App.js before auth (working)
import * as firebase from 'firebase';
import 'firebase/firestore';
if (firebase.apps.length === 0){
firebase.initializeApp(firebaseConfig);
}
export default class App extends React.Component {
render() {
return (
<NavigationContainer>
<RestaurantNavigator />
</NavigationContainer>
)
}
}
This is my App.js after auth (notWorking, see error of before)
import * as firebase from 'firebase';
import 'firebase/firestore';
import auth from '@react-native-firebase/auth';
if (firebase.apps.length === 0){
firebase.initializeApp(firebaseConfig);
}
function LoginApp(){
const [initializing, setInitializing] = useState(true);
const [user, setUser] = useState();
function onAuthStateChanged(user){
setUser(user);
if (initializing) setInitializing(false);
}
useEffect(() => {
const subscriber = auth().onAuthStateChanged(onAuthStateChanged);
return subscriber; // unsubscribe on unmount
}, []);
if (initializing) return null;
if (!user) {
return (
<View>
<Text>Login</Text>
</View>
);
}
}
export default class App extends Component {
render() {
return (
<View style = {styles.container}>
<LoginApp />
<NavigationContainer>
<RestaurantNavigator />
</NavigationContainer>
</View>
)
}
}
What i'm doing wrong?

