-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[Bug]: NavLink always active for root url #9261
Comments
I believe you need to add the
<NavLink to="/" end>Home</NavLink> |
Thanks it's working. But I always did it without the |
Ok weird, I have a few other projects using |
Same here : with rr 6.1 and 6.3 (not tested with 6.0 nor 6.2) |
I don't believe anything changed about Here's a quick code sandbox showing the behavior: https://codesandbox.io/s/navlink-end-behavior-otpymz?file=/src/index.js |
Thanks a lot for your reply and codesandbox, @brophdawg11, I played a little bit with it and I think that the problem seems to occur on root NavLinks ( In your code, if you navigate to Having parents active by default when children routes are visited seems legit, but having the "Home" link always active by default seems quite weird. Pre 6.4 versions were fine on this, don't you think ? |
Thank you for digging deeper into that @t-fritsch, I don't think any of us quite caught the nuance around the |
Awesome ! Thanks a lot @brophdawg11 🙏 |
So why is the root
Are the docs just flat out wrong? Have they been incorrect this entire time, save for v6.4.0-6.4.2? |
I think the docs were incorrect - updated in #10757. |
What version of React Router are you using?
6.4.0
Steps to Reproduce
Add to your navigation component and visit another page:
Expected Behavior
This code being compiled to
while being on any other route like
/about
Actual Behavior
This is compiled to:
while being on
/about
The text was updated successfully, but these errors were encountered: