question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React router NavLink exact property does not work

See original GitHub issue

When true, the active class/style will only be applied if the location is matched exactly.

<NavLink exact to="/users">
  Users
</NavLink>

Expectation: It should remove the active class when a user navigates /users/:id Actual result: It removes active class

Chakra-ui implementation

<Link
 as={NavLink}
 to="/users"
 exact
>
 Users
</Link>

Expectation: It should remove the active class when a user navigates /users/:id Actual result: It doesn’t remove active class

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
with-heartcommented, Jul 3, 2020

This is an issue with polymorphic as being incomplete in earlier Chakra versions. This prop now works as expected in 1.0, which is currently in pre-release status: https://codesandbox.io/s/elegant-frost-37n8n?file=/src/App.js

0reactions
aitsamahadcommented, Nov 6, 2020

@ljosberinn oh, sorry. I was just searching for this issue, read this discussion and saw that it isn’t solved so i just posted my problem here too. Didn’t saw that it is actually an official chakra-ui repo, my bad!

Read more comments on GitHub >

github_iconTop Results From Across the Web

NavLink exact prop not working for react-router-dom 6
The problem with NavLink of react-router-dom that i am facing now is that the root path "/" is always active, other paths are...
Read more >
Fix React Router navlink-exact when activeClass is not working
If you're adding navlinks with react router because you want to set the active class you might find that it doesn't work.
Read more >
NavLink - React Router: Declarative Routing for React.js
If the function className is used, the link's active state is passed as a parameter. This is helpful if you want to exclusively...
Read more >
Migrating to React Router v6: A complete guide
In this article, we'll look at issues with React Router v5, what changed, how to upgrade to v6, ... Specifying exact route paths...
Read more >
export 'navlink' (imported as 'navlink') was not found in 'react ...
Please try a fresh installation. There was a release (4.4) that caused a number of issues for people; that was unpublished and re-published...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found