'If useHistory hook is use in react, what hook will be used in replace of useHistory in Nextjs?
const loginUser = async (e) => {
e.preventDefault();
await axios.post(
"http://localhost:5000/api/login",
{
email,
password,
},
{ withCredentials: true }
);
fetchAllCars();
//I want to push the user to their history section here
console.log("success");
};
I wrote a logic that redirect a user to login page whenever they click on a protected route. This check if the user had signed in, if not, the logic will redirect the user to login page. So when the credentials are correct, I would like to return the user to the previous state in the home page before redirecting them to login page
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
