Skip to content

[v6] Why is NavLink and Link not the same component? #8275

Closed Answered by mjackson
rwieruch asked this question in Q&A
Discussion options

You must be logged in to vote

<NavLink> is really just a simple example of how to build a link that knows whether or not it is "active" by matching the beginning of the URL pathname. This is a common case in React Router because nested URL paths often correspond to nested UI.

There are other times when you might want a link to be active, such as when the URL contains a certain query parameter. For more complex cases, we provide the hooks for you to build your own <NavLink> as demonstrated in this example.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mjackson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants