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.