React Router Fixing NavLink isActive For Parent Route - gecko-8/devwiki GitHub Wiki

Up

Issue

When using nested routes and NavLink, the NavLink for the parent route is flagged as active as well as the current route.

Fix

Add the "end" attribute to the NavLink tag.

e.g.
<NavLink to="some/where" end>Go Somewhere</NavLink>

⚠️ **GitHub.com Fallback** ⚠️