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

127
Views
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 answers
Answer question

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 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!