Let's say that the flow of my website is as follow: a -> B -> C -> D or A -> B -> D
Let's say that I want to always get back from page D to page A. I can't use:
window.history.go(x)
because I have no idea how many steps it'll take to get from page A to page D.
Is there any way to remove steps between page A and D? Using native js or 'connected-react-router' library? I don't want to redirect from D to A. It'd be great if I could just remove elements between D and A from history and user could navigate from D to A using 'back button' in his browser.
"I don't want to redirect from D to A"
-> why thought?
I think the best option is to redirect from D to A
I know this don't answer the question but in your case user can go B - C - B - C ... etc
You can check if history in (B,C) then ignore but that's dirty... Redirect is more convenient in your case