Skip to content
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

Same link creates duplicates in location history #74

Open
vladshcherbin opened this issue Mar 29, 2019 · 1 comment
Open

Same link creates duplicates in location history #74

vladshcherbin opened this issue Mar 29, 2019 · 1 comment

Comments

@vladshcherbin
Copy link

Hey,

When clicking same link, it creates duplicates in history so when you click back, you get to the same page.

Tested on basic example.
Click home -> about -> about -> about -> back. You would expect to go back to home, but you will stay on the same page. Default browser <a> tag doesn't create same page history duplicates.

This is a well know bug in history package (since v4) which was reported multiple times in react-router (RR#5500, check number of linked issues) and in history (H#507).

React-router guys tell this should be fixed in history while history guy one day tells it should be fixed in react-router, next day says it should fixed in history and wants a pr, next day closes pr with no comments (H#570).

Maybe at least one router will have links that work same way as browser ones.

@jamesknelson
Copy link
Collaborator

So personally, I'd say this isn't a bug in history, but I do agree that it would be nice to solve it within the router. The reason I'd say that it isn't a bug in history is because this is how the browser's window.history works, and the history package should act as a thin wrapper around it.

The way to implement this I think is to add a condition to navigation.navigate(), that returns without navigating if all of the following conditions are true:

  • The new URL matches the existing URL
  • The existing URL has an empty state or no state object
  • The new URL has an empty state object or no state object

Would be happy to accept a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants