const navigate = useNavigate();
navigate(-1)
This is what I am trying to do. However, I want to know what the previous page is before going back. If the previous page is some other site, then of course, it should have no effect.
const navigate = useNavigate();
navigate(-1)
This is what I am trying to do. However, I want to know what the previous page is before going back. If the previous page is some other site, then of course, it should have no effect.
2
Answers
You can do a check to verify the url origin using
window.location.origin
.Yes, we can maintain some "state" to indicate that where it is navigated exactly from.
For Example:
So, from current page you can check that state and handle the navigation.