-
Notifications
You must be signed in to change notification settings - Fork 960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
top() to get the previous route #426
Comments
This is more of a routing issue than a history issue, but you should be able to just use |
@mjackson: I do not want to trigger a "go back", I want to be able to access what is in the state of the previous route from a stack prospective. That would enable us to render a " <-" in the navigation bar when the user is coming from a specific route or a default navigation when the user is coming from other routes. |
We currently render back/forward buttons on our website using memory history's |
Think for example if instead of a "<-" you want to have a label "back to messages" or "back to the homepage"... you cannot do that with The full solution consist in being able to inspect the top of the stack (where you are coming from). The back URL are a stack and it is pretty common for a stack to have a Currently as a workaround, I have to push extra info in the |
Since you're using memory history, just inspect |
Any news on this? Indeed being able to access previous route would be nice. My use case: this would make trivial redirecting a user once logged on the page he came from protected page => auth => protected page again |
You can already do this. There is nothing for us to add. |
@mjackson what do you mean? where can I find the previous route with History without keeping track of it myself? |
Inspect |
@mjackson thanks for helping! Maybe this is something related react-router-redux? Honestly docs and discussion around the web are very fragmented and I can't understand if this is related to history or react-router-redux module :(
|
@mjackson Can you please explain where |
@Dmitry1007 |
@mjackson can you please show us what is the proper way to get the previous route when using browser history then? |
@damianobarbati You can't. Browsers won't let you because it's a security issue. Just imagine if a website could read all the URLs that you had visited previous to coming to that site. It would be a violation of that user's privacy. |
@mjackson oh no I totally agree, but I didn't mean that! I meant how to read the same domain/website previous url without having to keep track of it xD Imagine this scenario:
|
We don't provide API for that in browsers because we don't have a reliable way to persist the data across page refreshes. You'll have to do it yourself. |
There are use cases (see for example the gmail app on android), where the navigation appearance depends from where you are coming from.
Considering back button and other behaviors, it would be great to have a
.top()
that returns the route where you go when you click the back button.The text was updated successfully, but these errors were encountered: