A react-router-dom NavLink only works after refresh not when clicking the nav item.
<NavLink
to="/test"
activeClassName="active">
test
</NavLink>
I don't get any errors on the page. When I clicked on the NavLink it updated my URL but did not apply the active class, I have to refresh the page to get the active class on the NavLink. Using v5
First you have to import NavLink.then you can directly set activeStyle to the styles you want.
import { NavLink } from 'react-router-dom';
<NavLink to="/test" activeClassName="active">
Test
</NavLink>
Style your class in the css by the property active:
.active{
color:#3895d3;
}