I am using vanilla React with react-router to build a simple master-detail SPA.
In the list page, i used push(*route*)
to navigate the user to a detail view, a back button on the detail view then calls goBack()
to navigate the user to the list view.
The reason for me to use the goBack()
function instead of push('/list')
is to allow the user to navigate back to the list view without losing filtering/pagination parameters (e.g. /list/1/10?q=abc).
The problem I have is, if the user started the browser from e.g. Google, then copy/paste the detail view url into the address bar, the goBack()
function will take them back to Google as Google was his last history.
Is there a way to check the goBack()
destination and decide to perform goBack()
based on whether the user will exit the application?