Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase.app() issue #8026

Open
Nagraj23 opened this issue Sep 18, 2024 · 2 comments
Open

Firebase.app() issue #8026

Nagraj23 opened this issue Sep 18, 2024 · 2 comments
Labels

Comments

@Nagraj23
Copy link

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' }}>


);
}

return (

<Stack.Navigator>
{user ? (
// If the user is logged in, show Home screen
<Stack.Screen name="Home" component={Home} options={{ headerShown: false }} initialParams={{ email: user.email }} />
) : (
// Otherwise, show the Login screen
<Stack.Screen name="Login" component={Login} options={{ headerShown: false }} />
)}
<Stack.Screen name='Hello User' component={Register} options={{headerShown:falselse}} />
</Stack.Navigator>

);
};

export default App;

@mikehardy
Copy link
Collaborator

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants