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/API.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,7 +103,7 @@ Please see the [`examples/`](/examples) directory of the repository for extensiv
103
103
### `<Link>`
104
104
The primary way to allow users to navigate around your application. `<Link>` will render a fully accessible anchor tag with the proper href.
105
105
106
-
A `<Link>` can know when the route it links to is active and automatically apply an `activeClassName` and/or `activeStyle` when given either prop. The `<Link>` will be active if the current route is either the linked route or any descendant of the linked route. To have the link be active only on the exact linked route, use [`<IndexLink>`](#indexlink) instead.
106
+
A `<Link>` can know when the route it links to is active and automatically apply an `activeClassName` and/or `activeStyle` when given either prop. The `<Link>` will be active if the current route is either the linked route or any descendant of the linked route. To have the link be active only on the exact linked route, use [`<IndexLink>`](#indexlink) instead or set the `onlyActiveOnIndex` prop.
107
107
108
108
#### Props
109
109
##### `to`
@@ -129,6 +129,9 @@ The styles to apply to the link element when its route is active.
129
129
##### `onClick(e)`
130
130
A custom handler for the click event. Works just like a handler on an `<a>` tag - calling `e.preventDefault()` will prevent the transition from firing, while `e.stopPropagation()` will prevent the event from bubbling.
131
131
132
+
##### `onlyActiveOnIndex`
133
+
If `true`, the `<Link>` will only be active when the current route exactly matches the linked route.
134
+
132
135
##### *others*
133
136
You can also pass props you'd like to be on the `<a>` such as a `title`, `id`, `className`, etc.
134
137
@@ -150,7 +153,7 @@ Given a route like `<Route path="/users/:userId" />`:
150
153
```
151
154
152
155
### `<IndexLink>`
153
-
An `<IndexLink>` is like a [`<Link>`](#link), except it is only active when the current route is exactly the linked route.
156
+
An `<IndexLink>` is like a [`<Link>`](#link), except it is only active when the current route is exactly the linked route. It is equivalent to `<Link>` with the `onlyActiveOnIndex` prop set.
154
157
155
158
### `<RouterContext>`
156
159
A `<RouterContext>` renders the component tree for a given router state. Its used by `<Router>` but also useful for server rendering and integrating in brownfield development.
0 commit comments