You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/components/nav-link.md
+4-16Lines changed: 4 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,29 +84,17 @@ You can pass a render prop as children to customize the content of the `<NavLink
84
84
85
85
The `end` prop changes the matching logic for the `active` and `pending` states to only match to the "end" of the NavLink's `to` path. If the URL is longer than `to`, it will no longer be considered active.
86
86
87
-
Without the end prop, this link is always active because every URL matches `/`.
88
-
89
-
```tsx
90
-
<NavLinkto="/">Home</NavLink>
91
-
```
92
-
93
-
To match the URL "to the end" of `to`, use `end`:
94
-
95
-
```tsx
96
-
<NavLinkto="/"end>
97
-
Home
98
-
</NavLink>
99
-
```
100
-
101
-
Now this link will only be active at `"/"`. This works for paths with more segments as well:
|`<NavLink to="/tasks" end />`|`/tasks/123`| false |
109
93
94
+
**A note on links to the root route**
95
+
96
+
`<NavLink to="/">` is an exceptional case because _every_ URL matches `/`. To avoid this matching every single route by default, it effectively ignores the `end` prop and only matches when you're at the root route.
97
+
110
98
## `caseSensitive`
111
99
112
100
Adding the `caseSensitive` prop changes the matching logic to make it case sensitive.
0 commit comments