React router dom is not redirecting to the route even though the url is changed

Hey I am facing a error. when I try to log in with my admin account on a website I am working in. The url changes but it doesn't redirect me to the admin dashboard. If I reload the website then I will be redirected to the admin dashboard and the issue won't come in if I don't reload after logging out. Why am I getting this error and how to fix it ?
7 Replies
missymae
missymaeβ€’11mo ago
I guess some problem with how you've written your router or outlet. Maybe something isn't nested correctly. But you will need to share actual code for anyone to suggest a fix.
dys πŸ™
dys πŸ™β€’11mo ago
Are you using <Link> tags?
Manish Karki
Manish KarkiOPβ€’11mo ago
No I am checking the type of user and then navigating to their dashboard with useNavigate hook Which codes should I post? I mean of which component ?
dys πŸ™
dys πŸ™β€’11mo ago
Try useHistory. (Or maybe not. I've got to figure out which documentation I'm looking at…)
Manish Karki
Manish KarkiOPβ€’11mo ago
Can't use useHistory
dys πŸ™
dys πŸ™β€’11mo ago
Yeah, I was in the wrong documentation, sorry. <:sad_google:400614345672884234>
Manish Karki
Manish KarkiOPβ€’11mo ago
This issue only comes when in the beggining or if I refresh page when I logged out. Otherwise it works fine.
Want results from more Discord servers?
Add your server