The problem I'm facing is that when a user clicks on a custom back button on my web page, I want it to navigate the user to a different page than they were previously on.
For example, a user is browsing around on www.mywebpage.com/. The user then clicks on a link to go to www.mywebpage.com/foo/bar. When the user clicks on the back button, I would like to back-navigate them to www.mywebpage.com/foo.
How can I achieve this with react router? Preferably using the hooks method or whatever is best.
I'm currently using react-router v5.