I want to use navigate() to go back in history, but TypeScript shows me an error: TS2345: Argument of type 'number' is not assignable to parameter of type 'To'.
How can I fix this issue?
const navigate = useNavigate()
useEffect(() => {
setIsLoading(true);
dispatch(fetchUser(userId!))
.unwrap()
.then(({ data }: { data: User }) => {
setIsLoading(false);
setUser(data);
})
.catch(() => navigate(-1, { replace: true }));
}, []);