Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
React Native (React Navigation)<> Firebase login screen

I'm using Firebase to keep track of all the users. I was able to connect Firebase. User registration is working fine.

I'm having issues with logging the users. When I enter login and password, the app doesn't redirect me to the right screen, and also throws this warning [Unhandled promise rejection: TypeError: navigation.navigation is not a function. (In 'navigation.navigation("myProfile")', 'navigation.navigation' is undefined)]

Here is how I do it

import { useNavigation } from "@react-navigation/native";
import React, { useEffect, useState } from "react";
import { View, ...} from "react-native";
import { auth } from "../firebase";

const Profile = () => {
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");

  const navigation = useNavigation();

   useEffect(() => {
     const unsubscribe = auth.onAuthStateChanged((user) => {
       if (user) {
         navigation.navigation("myProfile");
       }
     });
     return unsubscribe;
   }, []);


  const signIn = () => {
    auth
      .signInWithEmailAndPassword(email, password)
      .then((userCredentials) => {
        const user = userCredentials.user;
        console.log("Sign In user.email = " + user.email);
      })
      .catch((error) => alert(error.message));
  };
//more code 

I also tried this, but it didn't help

import React, { useEffect, useState } from "react";
import { View, ...} from "react-native";
import { auth } from "../firebase";

const Profile = ({navigation}) => {
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");
    
   useEffect(() => {
     const unsubscribe = auth.onAuthStateChanged((user) => {
       if (user) {
         navigation.navigation("myProfile");
       }
     });
     return unsubscribe;
   }, []);

//more code 

I'm not sure if I need to navigation.navigation("myProfile") onPress or it has to be inside of the the useEffect

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use

navigation.navigate("myProfile")

instead of

navigation.navigation("myProfile");

Also you can destruct your hook object like this

const { navigate } = useNavigation()

in order to just write

navigate("myProfile")

I'm not sure if I need to navigation.navigation("myProfile") onPress or it has to be inside of the the useEffect

Most of the cases you should move the user to home screen (logged in user screen) when the signIn function returns true and the user is logged in, so in this case I think you have to use navigate("myProfile") inside of

auth
  .signInWithEmailAndPassword(email, password)
  .then((userCredentials) => {
    ...your code
    navigation.navigate("myProfile")
  })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!