React Router NavLink
Question
What does NavLink do in React Router?
Hint
NavLink adds "active" class when the route matches.
Explanation
NavLink is a React Router component that renders an anchor tag with active styling when the current URL matches its "to" prop. It adds an "active" class by default, or you can customize with isActive prop or className/function. <NavLink to="/home" className={({isActive}) => isActive ? "bold" : ""}>Home</NavLink>. Use NavLink for navigation menus where active state matters. Regular Link does not track active state. NavLink supports "end" prop to only match exact paths.
Related Resources
Related Lessons
- React Router
Learn routing.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.