Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!