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

189
Visualizações
firebase.auth().currentUser returning an object with undefined properties? Reactjs

here is my code:

const [user] = useAuthState(auth);

function submitPostHandler() {
    if (user) {
        const currentUser = auth.currentUser;
        firestore.collection("posts").add({
            title: title,
            desc: desc,
            imgUrl: imgUrl,
            poster: currentUser.displayName,
            createdAt: new Date().toISOString(),
            comments: []
        });
        console.log(currentUser);
        //navigate("/all-posts");
    }
    else {
        navigate("/login");
    }
}

Simple, whenever I run this function it logs an object that has properties that are undefined as in if I switch console.log(currentUser); with console.log(currentUser.displayName) it logs undefined. Unusually useAuthState(); returns true.

It seems like when I was creating the user with the createUserWithEmailAndPassowrdOrSomething() I was not passing in the email and password. I forgot to change this when @Dharmaraj told me before.

about 4 years ago · Juan Pablo Isaza
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