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

162
Views
My AuthContext works for a while, and shows the displayname, then i get this error once the page refresh

Using Firebase 9: When i comment out the user.displayname, no errors. When i uncomment, it will show the displayName in the Navbar, however when i refresh the page or click away i will get the following errors below

TypeError: Cannot read properties of null (reading 'displayName')

src/components/Navbar.js:13
  10 | return (
  11 |   <nav>
  12 |     <h1>My Reading List</h1>
> 13 |     <p>{user.displayName}</p>
     | ^  14 |     <ul>
  15 |       <li>
  16 |         <Link to="/">Home</Link>
(anonymous function)
src/context/AuthContext.js:28
  25 | 
  26 | useEffect(() => {
  27 |   const unsub = onAuthStateChanged(auth, (user) => {
> 28 |     dispatch({ type: "AUTH_IS_READY", payload: user });
     | ^  29 |     unsub();
  30 |   });
  31 | }, []);
 514 | _assert(promise, this, AuthErrorCode.INTERNAL_ERROR);
  515 | // The callback needs to be called asynchronously per the spec.
  516 | // eslint-disable-next-line @typescript-eslint/no-floating-promises
> 517 | promise.then(() => cb(this.currentUser));
      | ^  518 | 
  519 | if (typeof nextOrObserver === 'function') {
  520 |   return subscription.addObserver(nextOrObserver, error, completed)```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I realised that the error was coming due to authentication state in route guarding. When you apply route guarding, make sure you set your permissions correctly

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!