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
TypeError: X is not a function when calling custom hook

I'm trying to write a simple login page. I want to pass the token generated from the login component to my auth component which will set context, and then send the user back to the home page after login. I'm running into an issue trying to call the useAuthContext hook inside the handleLogin element. Here's I think the relevant code:

const authState = useAuthState();
const handleLogin = accessToken => {
  console.log(accessToken);
  authState({ accessToken });
  history.push("/");
}

handleLogin gets called with the onSuccess handler in the login component.

I get an error that authState is not a function.

I've looked at code samples that seem to work just like this when needing to call a hook inside an arrow function, so not sure what I'm doing wrong.

Edit: Problem is staring at me in the face. authState is not a value under my Context Provider. Problem solved.

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