goBackN()?
I do have a site where you can open a popup. From this popup you can navigate deeper. I mapped all those subpages of the popup to the url and that works great.
What I want to do now is close this popup, e.g. navigate a certain amount of steps back.
I implemented goBackN(n) myself by just calling goBack() n times.
This works on chrome, but not on android and ios. There it only goes back once, ignoring the repeated calls.
transitionTo(...) doesn't work either in my case, see illustration below:
app/foo
app/foo/popup #open popup
app/foo/popup/1 #navigate deeper
app/foo/popup/1/2 #navigate deeper
app/foo #close the popup using transitionTo('foo')
app/foo/popup/1/2 #user pressed browser back button, NOT what I want
#correct would be: "app"
What other options do I have? Can I use transitionTo(...) and then directly modify the history somehow?
If you know the exact amount of steps to go back, and if you use HistoryLocation, I think right now it would be easiest to bypass the router: window.history.go(-n).
Thanks a lot for your very quick response, this works fine!
But it seems a bit hacky to bypass the router, can this potentially cause any problems in the future?
I'm closing this now, as it currently works for me. But maybe this use case should be implemented in react router, as others might run into the same problem?