-
Notifications
You must be signed in to change notification settings - Fork 94
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
Pathname Environment, History API and a double click in the back button to go back? #194
Comments
The history api is used by default as you follow links. Just make links as you normally would (or use the |
Can you provide more information on your solution? I'm not sure how to implement what you described. I have a component handling redirects that I call when I want to navigate in the app so I'm not using the Link component:
Would this component be the reason why the history api isn't working as it should? Perhaps the replace true? This Redirect component wasn't added by me, hence the odd questions. :/ |
Looking at the implementation of navigate...it definitely seems like the replace: true is the reason why the back fails... |
Redirects are supposed to replace the current entry of history, if you redirect from a route, you aren't supposed to be able to go back... If you are forwarding someone after a condition, you may want to add a prop (defaulted to true) that allows you to use Redirect but not replace history. |
Nonetheless, you don't need to directly access or use the history api with this component... it handles it for you. |
Putting replace as false did allow the history api to work as planned. In this case the redirect is being used to navigate in the app, what could be used instead then? |
You are using Links primarily to navigate, right? You shouldn't need to programmatically navigate 99% of the time. Using Redirect to navigate your app in this fashion is fine, I was just suggesting that you make your Redirect optionally not replace history for this (seemingly) one off case. (Redirects are typically route replacements, not additional routes...and you typically don't want the back button landing you on that route again) |
I apologize if this isn't the correct place to ask my question, but I can't seem to figure this out.
I'm currently using version 0.32.2 of the react-router-component and I'm having difficulties with using the History API along with the react-router-component.
I know I'm using the PathnameEnvironment as the default environment since I didn't set hash as true in the Locations, as shown below:
I was looking at one of the tests for PathEnvironment, and tried to somewhat mimic its behavior, but while the react-router-component detects a popstate event, the path isn't changing (I confirmed it by placing a console.log in the popstate listener of PathnameEnvironment)...it only changes if I click twice in the back button. I can also see that whenever I navigate, only one entry is added to the browser's back history button. Am I doing anything wrong or missing anything? :/
The text was updated successfully, but these errors were encountered: