I am currently developing a site and I have made the logic for the login process so that the system automatically transfers the user to the home page as soon as the login process is completed, but when I try to log in, an error appears in the browser
I tried using history and it didn’t work, then I tried useNavigate and it didn’t work either
I think usehistory is no longer supported in the new react version but even useNavigate is not working
2
Answers
Oh, you need to import
useNavigate
fromreact-router-dom
, and then use this hook in your application. You can learn more about navigating here.Here is your code: