I am developing an application in which there is a rule that on a specific page I need to intercept the browser’s back button and send it to another page other than the previous one.
So far I haven’t found anything, just a few examples using class components or older versions of React Router Dom, I’ve also seen examples using something like the example below, but nothing has worked, has anyone experienced this situation or something similar or has an idea of how I can solve this problem?
window.onpopstate = () => {
navigate("/");
}