invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.65k stars 2.21k forks source link

Firebase.app() issue #8026

Open Nagraj23 opened 6 days ago

Nagraj23 commented 6 days ago

i have installed the "dependencies": { "@react-native-async-storage/async-storage": "^2.0.0", "@react-native-firebase/app": "^20.5.0", "@react-native-firebase/auth": "^20.5.0", "@react-native-firebase/firestore": "^20.5.0", this dependancies and still i am encountering with the same issue multiple times and the error is as follows : Error: You attempted to use a Firebase module that's not installed natively on your project by calling firebase.app().

Ensure you have installed the npm package '@react-native-firebase/app', have imported it in your project, and have rebuilt your native application.

This error is located at: in App in RCTView (created by View) in View (created by AppContainer) in RCTView (created by View) in View (created by AppContainer) in AppContainer in main(RootComponent), js engine: hermes i have reinstalled the dependancies also but also the issue isnt solved please check it once and the app.js file is as follows : import React, { useState, useEffect } from 'react'; import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator } from '@react-navigation/stack'; import firebase from '@react-native-firebase/app'; import auth from '@react-native-firebase/auth'; import Login from './components/Login'; import Register from './components/Register'; import Home from './components/Home'; import { ActivityIndicator, View } from 'react-native';

const Stack = createStackNavigator();

const App = () => { const [user, setUser] = useState(null); const [loading, setLoading] = useState(true); // Add loading state

// useEffect(() => {

// if (!firebase.apps.length) { // firebase.initializeApp(); // } else { // firebase.app(); // } // }, []);

useEffect(() => { const unsubscribe = auth().onAuthStateChanged(user => { setUser(user); setLoading(false); }); return unsubscribe; }, []);

if (loading) { // Show loading indicator while checking auth status return ( <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>

  </View>
);

}

return (

{user ? ( // If the user is logged in, show Home screen ) : ( // Otherwise, show the Login screen )}

); };

export default App;

mikehardy commented 6 days ago

Hi there! You deleted the template so it's hard to say if you are using Expo or not. However, this native-module-not-installed problem is always the result of an incomplete integration If you're using Expo, you need to add all the config plugins If you are doing a bare react-native project you might look at the integration steps required to get things working - this script does every single one and starts from npx react-native init then goes all the way to a functioning app https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

There will be no change in this repository in response to the issue, it's going to be a local fix you have to make after studying up more on how to integrate it

Nagraj23 commented 5 days ago

Okk I'll check the integration steps and thnks for the guidance