javascriptreactjsreact-routerreact-router-v4

React Router v4 <NavLink> vs <Link> benefits


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?


Solution

  • 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.