Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
auth.currentUser shows undefined on HomePage

I have a file where I have written all the firebase related functions, including this one here

function CurrentUser(){
console.log("auth", auth)
return auth.currentUser }

When I log auth.currentUser inside the function above, I can see details of currently logged in user but when I call this function on React homepage, I see it being undefined. Also I could see the homepage logs as expected if I make any changes like adding let i=1 in the above function. Wasn't able to figure out what's going on here. Any help would be appreciated.

Code for the call. This is to be on the homepage.

const Home() = () =>{
let userName = Firebase.CurrentUser();
console.log("userName", userName);
}

Output for when I log in to the app:

output with the issue

Output when I add something like a new variable to any of the above functions:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It looks like auth has a value, but auth.currentUser doesn't. That is actually very common when you're just loading the app/page, as refreshing the user credentials requires a call to the server and takes time.

If you want your app to respond to those change, implement onAuthStateChanged as shown in the first snippet in the documentation on getting the current user.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda