I need help trying to redirect already logged user(using cookies) to the homepage, whenever the user tries to go to login page.
Here is what I’m trying to do
I am using useAuth, hook that just calls the AuthContext.
Here is the AuthProvider
I tried this method but I get in an infinite loop and my app just crashes.
I tried also putting this in a useEffect() hook but in React using a useAuth hook in a useEffect hook is forbidden so that didn’t work too.
I am trying to read the cookies, and if there are some, save them in my AuthContext so that the user is logged in the homepage, and redirected whenever tries to go to login page
Axel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.