Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda