Junior From PDF React React.js

What is the difference between Link and NavLink? Feature Link NavLink Purpose Navigate between pages Navigation with active styling

ctive

style

No built-in active

style

utomatically adds an active class when the route is

ctive

Use case Basic navigation For creating navigation menus with active links (e.g.,

highlighting the active link)

Example of NavLink:

import { NavLink } from 'react-router-dom';

function Navbar() {

return (

<nav>

<NavLink to="/" activeClassName="active">Home</NavLink>

<NavLink to="/about" activeClassName="active">About</NavLink>

</nav>

);

}

More from React.js Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details