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

<Link/> component updates history even when location is the same #5500

Closed
vladshcherbin opened this issue Sep 7, 2017 · 1 comment
Closed

Comments

@vladshcherbin
Copy link
Contributor

vladshcherbin commented Sep 7, 2017

Version

4.2.2

Test Case

https://codesandbox.io/s/23v4l0o9l0

Steps to reproduce

Click on Home page link many times, each click creates a new history item. Home page is re-rendered every time. Now your browser navigation is broken (back/forward buttons are not working as expected).

Expected Behavior

Clicks on <Link /> component should not add new history items when location is the same.

Default browser <a> tag doesn't create history duplicates. This bug was introduced in RR v4 with history v4, RR v3 had correct behavior.

Actual Behavior

Each click on <Link /> component adds new history item, even when location is the same.

This creates a lot of problems, some of them:

  • website links are working wrong according to WHATWG browser spec
  • same links create history duplicates which confuses browser back/forward navigation
  • history duplicates messes up route animations logic
  • links behavior differs from 99% of websites
  • same component re-renders on every click (not sure if this is related)

Related issues

There are a lot of related issues, some of them:

RR #5362 #5039 #5363
History #470 #507 #472

All of this issues are ignored with an excuse that history v4 needs to fix this but until it's not fixed there it has to be fixed in react-router because it is a breaking change from RR v3, RR v4 is not following browser specs and this bug is creating a lot of problems.

@timdorr
Copy link
Member

timdorr commented Sep 7, 2017

As stated before in the issues you linked, this is something history has to solve. We cannot and should not try to patch around it, because it will result in behavior differences between Link and history.push usage.

BTW, I'm not closing this because it's not an issue (it definitely is!), but just because this is in the wrong repo. I would keep pushing on remix-run/history#507 to solve it. A PR will be the best way, since it gives us something actionable to work with.

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

No branches or pull requests

2 participants