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

156
Visualizações
Firebase onAuthStateChanged listener never fires on localhost despite being authorized

Fairly experienced with Firebase, encountering a strange and unintuitive bug. I've written a Firebase authentication wrapper using the React Context API, and track the currently logged in user with a listener. Here is my code:

useEffect(() => {
  console.log("Registering firebase auth listener");

  const unsubscribe = fa.onAuthStateChanged(
    fa.getAuth(),
    function (user) {
      console.log(user);
      setCurrentUser(user);
    },
    (error) => console.error(error),
    () => console.warn("Firebase listener unhooked")
  );

  return unsubscribe;
}, []);

Up until recently, this worked fine, but something has caused it to stop working only on localhost with no error message. The print at the top for checking that the hook runs gets logged, but nothing else.

Localhost is approved in the firebase dashboard

I don't understand what's going on here. Is there something obvious I've missed?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Solved my problem. I'd accidentally removed the initialization of firebase. To anyone reading this, if your onAuthStateChanged is mysteriously not firing, make sure you run initializeApp first.

If you're importing the intialization from another module, make sure you import the initialization code first.

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