Skip to content

Don't add new location to history when navigating to the current URL #5039

@rhernandog

Description

@rhernandog

Version

4.1.1

Test Case

https://reacttraining.com/react-router/web/example/basic

Steps to reproduce

Click on the "About" link several times, the the previous button

Expected Behavior

If the Link's to param is the current history location pathname, don't push it to the history, so if the user clicks the back button, it actually goes back to the previous component, not the current one again.

Actual Behavior

The history object keeps pushing the same url over and over, so if you click the previous button the same component is rendered again. I understand that there could be some other params on the url, so the question also would be, is there too much code and performance overhead on adding a regex check in order to see if the url location is the same and use the rest of the params for the intend purposes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions