Default location on back in empty stack
turnerhayes opened this issue · 2 comments
I don't know if this is a common use case, but I have a case where I want the user to be able to back out of an action, and it might be useful to take them to some default location if the history stack is empty (say, they opened a link in a new tab).
For a little more detail, the user is on a page for joining a game, but if they decide they don't want to join, I want to give them the opportunity to get out easily. My idea is to give them a button to go back, but if their stack is empty, it'll do nothing. That's not the end of the world--they can always close the tab, of course--but it would probably be better to go to the homepage or something. I could use the history API to branch the logic, but it would be handy to be able to do something like
this.props.dispatch(goBack({ default: "/" })
so that it would go to the / route if there's nothing before it on the stack.
This isn't how the browser itself works, so this kind of thing isn't possible through go calls.
I can see not wanting to break with standard browser behavior, but it does seem possible to do; all we'd need is to have access to the history stack.