Replies: 1 comment
|
Pushing a duplicate URL to the browser history stack is intentional and mirrors standard HTML5 History API ( There are valid scenarios where pushing the same path is required:
Because this is standard browser behavior, React Router leaves history stack control to the caller rather than auto-filtering identical pushes. Idiomatic Solutions1. Use
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
When using
useNavigate, navigating to the currently active route still pushes a duplicate entry onto the browser history stack.If the user is already on
/contents/blog, clicking the button adds another identical history entry. This causes the browser back button to navigate to the same page again, which can feel broken from a UX perspective.Currently, developers need to manually guard against this:
Proposed Solutions
Option 1
Option 2
Would it be okay if I worked on a PR for this?
All reactions