Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda