Besides the ability to set an "activeClassName" and "activeStyle" on NavLink, is there any reason to use NavLink over Link when creating links to other routes on non-navigational elements (ie. not main nav in header or footer) on your site that don't need an active state/class?
4 Answers
The official documentation is clear:
<NavLink>A special version of the
<Link>that will add styling attributes to the rendered element when it matches the current URL.
Thus, the answer is NO. There are no other reasons except the mentioned one.
Link Component
It is used to create links which allow to navigate on different URLs and When we click on any of that particular Link, it should load that page which is associated with that path without reloading the page. Example:
NavLink Component:
If, we want to add some styles to the Link. So that when we click on any particular link, it can be easily identified which Link is active. For this react router provides NavLink instead of Link. Now replace Link from Navlink and add properties activeStyle. The activeStyle properties mean when we click on the Link, it should be highlighted with different style so that we can differentiate which link is currently active. Example:


NavLinkkeeps the proper focus on the page for accessibility. When using link, initial focus is lost on page load and you will also notice that tabbing through dropdowns also breaks when usingLink. NavLink fixes this. - DJNorris