September 2018
Beginner
156 pages
3h 28m
English
When you click on the <NavLink> with the to prop /dashboard, the active class (or inline style specified in activeStyle prop) is applied to both the <NavLink> components in the page. Similar to the <Route> component, the / in /dashboard matches the path specified in the to prop, and thus the active class is applied to both the <NavLink> components.
In this case, the exact prop can be used to apply the active class or activeStyle only when the path matches the browser's URL:
<NavLink to="/" exact> Home</NavLink><NavLink to="/dashboard" activeClassName="selectedLink"> Dashboard</NavLink>
Read now
Unlock full access