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
* Returns a PathMatch object if the given pattern matches the current URL.
164
+
* Returns a {@linkPathMatch} object if the given pattern matches the current URL.
165
165
* This is useful for components that need to know "active" state, e.g.
166
-
* `<NavLink>`.
166
+
* {@link NavLink | `<NavLink>`}.
167
167
*
168
168
* @public
169
169
* @category Hooks
170
-
* @param pattern The pattern to match against the current location
171
-
* @returns The path match object if the pattern matches, null otherwise
170
+
* @param pattern The pattern to match against the current {@link Location}
171
+
* @returns The path match object if the pattern matches, `null` otherwise
172
172
*/
173
173
exportfunctionuseMatch<
174
174
ParamKeyextendsParamParseKey<Path>,
@@ -219,16 +219,16 @@ function useIsomorphicLayoutEffect(
219
219
*
220
220
* It's often better to use {@link redirect} in [`action`](../../start/framework/route-module#action)/[`loader`](../../start/framework/route-module#loader) functions than this hook.
221
221
*
222
-
* The returned function signature is `navigate(to, options?)/navigate(delta)` where:
222
+
* The returned function signature is `navigate(to, options?)`/`navigate(delta)` where:
223
223
*
224
-
* * `to` can be a string path, a `To` object, or a number (delta)
224
+
* * `to` can be a string path, a {@link To} object, or a number (delta)
225
225
* * `options` contains options for modifying the navigation
226
-
* * `flushSync`: Wrap the DOM updates in `ReactDom.flushSync`
226
+
* * `flushSync`: Wrap the DOM updates in [`ReactDom.flushSync`](https://react.dev/reference/react-dom/flushSync)
227
227
* * `preventScrollReset`: Do not scroll back to the top of the page after navigation
228
-
* * `relative`: "route" or "path" to control relative routing logic
229
-
* * `replace`: Replace the current entry in the history stack
230
-
* * `state`: Optional history state to include with the new `Location`
231
-
* * `viewTransition`: Enable `document.startViewTransition` for this navigation
228
+
* * `relative`: `"route"` or `"path"` to control relative routing logic
229
+
* * `replace`: Replace the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History) stack
230
+
* * `state`: Optional history state to include with the new {@linkLocation}
231
+
* * `viewTransition`: Enable [`document.startViewTransition`](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for this navigation
232
232
*
233
233
* @example
234
234
* import { useNavigate } from "react-router";
@@ -250,7 +250,7 @@ function useIsomorphicLayoutEffect(
250
250
* navigate("/some/route?search=param");
251
251
* ```
252
252
*
253
-
* ### Navigate with a `To` object
253
+
* ### Navigate with a {@link To} object
254
254
*
255
255
* All properties are optional.
256
256
*
@@ -273,17 +273,17 @@ function useIsomorphicLayoutEffect(
273
273
* navigate(-1);
274
274
*
275
275
* // forward
276
-
* // often used in a multi-step wizard workflows
276
+
* // often used in a multistep wizard workflows
277
277
* navigate(1);
278
278
* ```
279
279
*
280
-
* Be cautions with `navigate(number)`. If your application can load up to a route that has a button that tries to navigate forward/back, there may not be a history entry to go back or forward to, or it can go somewhere you don't expect (like a different domain).
280
+
* Be cautious with `navigate(number)`. If your application can load up to a route that has a button that tries to navigate forward/back, there may not be a `[`History`](https://developer.mozilla.org/en-US/docs/Web/API/History) entry to go back or forward to, or it can go somewhere you don't expect (like a different domain).
281
281
*
282
-
* Only use this if you're sure they will have an entry in the history stack to navigate to.
282
+
* Only use this if you're sure they will have an entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History) stack to navigate to.
283
283
*
284
284
* ### Replace the current entry in the history stack
285
285
*
286
-
* This will remove the current entry in the history stack, replacing it with a new one, similar to a server side redirect.
286
+
* This will remove the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History) stack, replacing it with a new one, similar to a server side redirect.
287
287
*
288
288
* ```tsx
289
289
* navigate("/some/route", { replace: true });
@@ -296,13 +296,13 @@ function useIsomorphicLayoutEffect(
296
296
* <br/>
297
297
* <br/>
298
298
*
299
-
* To prevent `<ScrollRestoration>` from resetting the scroll position, use the `preventScrollReset` option.
299
+
* To prevent {@link ScrollRestoration | `<ScrollRestoration>`} from resetting the scroll position, use the `preventScrollReset` option.
* For example, if you have a tab interface connected to search params in the middle of a page and you don't want it to scroll to the top when a tab is clicked.
305
+
* For example, if you have a tab interface connected to search params in the middle of a page, and you don't want it to scroll to the top when a tab is clicked.
* Returns an object of key/valuepairs of the dynamic params from the current URL that were matched by the routes. Child routes inherit all params from their parent routes.
422
+
* Returns an object of key/value-pairs of the dynamic params from the current URL that were matched by the routes. Child routes inherit all params from their parent routes.
423
423
*
424
424
* Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
425
425
*
@@ -530,7 +530,7 @@ export function useParams<
530
530
}
531
531
532
532
/**
533
-
* Resolves the pathname of the given `to` value against the current location. Similar to {@link useHref}, but returns a {@link Path} instead of a string.
533
+
* Resolves the pathname of the given `to` value against the current {@link Location}. Similar to {@link useHref}, but returns a {@link Path} instead of a string.
534
534
*
535
535
* @example
536
536
* import { useResolvedPath } from "react-router";
@@ -547,9 +547,9 @@ export function useParams<
547
547
* @category Hooks
548
548
* @param to The path to resolve
549
549
* @param options Options
550
-
* @param options.relative Defaults to "route" so routing is relative to the route tree.
551
-
* Set to "path" to make relative routing operate against path segments.
552
-
* @returns The resolved `Path` object with pathname, search, and hash
550
+
* @param options.relative Defaults to `"route"` so routing is relative to the route tree.
551
+
* Set to `"path"` to make relative routing operate against path segments.
552
+
* @returns The resolved {@linkPath} object with `pathname`, `search`, and `hash`
553
553
*/
554
554
exportfunctionuseResolvedPath(
555
555
to: To,
@@ -576,7 +576,6 @@ export function useResolvedPath(
576
576
* The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
577
577
*
578
578
* @example
579
-
* import * as React from "react";
580
579
* import { useRoutes } from "react-router";
581
580
*
582
581
* function App() {
@@ -601,7 +600,7 @@ export function useResolvedPath(
601
600
* @public
602
601
* @category Hooks
603
602
* @param routes An array of route objects that define the route hierarchy
604
-
* @param locationArg An optional location object or pathname string to use instead of the current location
603
+
* @param locationArg An optional {@link Location} object or pathname string to use instead of the current {@link Location}
605
604
* @returns A React element to render the matched route, or `null` if no routes matched
606
605
*/
607
606
exportfunctionuseRoutes(
@@ -1172,7 +1171,7 @@ export function useRouteId() {
1172
1171
}
1173
1172
1174
1173
/**
1175
-
* Returns the current navigation, defaulting to an "idle" navigation when no navigation is in progress. You can use this to render pending UI (like a global spinner) or read FormData from a form navigation.
1174
+
* Returns the current {@link Navigation}, defaulting to an "idle" navigation when no navigation is in progress. You can use this to render pending UI (like a global spinner) or read [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) from a form navigation.
1176
1175
*
1177
1176
* @example
1178
1177
* import { useNavigation } from "react-router";
@@ -1188,17 +1187,18 @@ export function useRouteId() {
* Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
1198
+
* Revalidate the data on the page for reasons outside of normal data mutations like [`Window` focus](https://developer.mozilla.org/en-US/docs/Web/API/Window/focus_event) or polling on an interval.
1200
1199
*
1201
1200
* @example
1201
+
* ```tsx
1202
1202
* import { useRevalidator } from "react-router";
1203
1203
*
1204
1204
* function WindowFocusRevalidator() {
@@ -1214,8 +1214,9 @@ export function useNavigation(): Navigation {
1214
1214
* </div>
1215
1215
* );
1216
1216
* }
1217
+
* ```
1217
1218
*
1218
-
* Note that page data is already revalidated automatically after actions. If you find yourself using this for normal CRUD operations on your data in response to user interactions, you're probably not taking advantage of the other APIs like {@link useFetcher}, {@link Form}, {@link useSubmit} that do this automatically.
1219
+
* Note that page data is already revalidated automatically after [`action`](../../start/framework/route-module#action)s. If you find yourself using this for normal CRUD operations on your data in response to user interactions, you're probably not taking advantage of the other APIs like {@link useFetcher}, {@link Form}, {@link useSubmit} that do this automatically.
1219
1220
*
1220
1221
* @public
1221
1222
* @category Hooks
@@ -1240,14 +1241,14 @@ export function useRevalidator(): {
1240
1241
}
1241
1242
1242
1243
/**
1243
-
* Returns the active route matches, useful for accessing loaderData for
1244
+
* Returns the active route matches, useful for accessing `loaderData` for
1244
1245
* parent/child routes or the route "handle" property
1245
1246
*
1246
1247
* @public
1247
1248
* @category Hooks
1248
1249
* @mode framework
1249
1250
* @mode data
1250
-
* @returns An array of UI matches for the current route hierarchy
1251
+
* @returns An array of {@link UIMatch | UI matches} for the current route hierarchy
1251
1252
*/
1252
1253
exportfunctionuseMatches(): UIMatch[]{
1253
1254
let{ matches, loaderData }=useDataRouterState(
@@ -1280,7 +1281,7 @@ export function useMatches(): UIMatch[] {
1280
1281
* @category Hooks
1281
1282
* @mode framework
1282
1283
* @mode data
1283
-
* @returns The data returned from the route's loader function
1284
+
* @returns The data returned from the route's [`loader`](../../start/framework/route-module#loader) or [`clientLoader`](../../start/framework/route-module#clientloader) function
* @param routeId The ID of the route to return loader data from
1319
-
* @returns The data returned from the specified route's loader function, or undefined if not found
1320
+
* @returns The data returned from the specified route's [`loader`](../../start/framework/route-module#loader) function, or `undefined` if not found
1320
1321
*/
1321
1322
exportfunctionuseRouteLoaderData<T=any>(
1322
1323
routeId: string
@@ -1326,7 +1327,7 @@ export function useRouteLoaderData<T = any>(
1326
1327
}
1327
1328
1328
1329
/**
1329
-
* Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
1330
+
* Returns the [`action`](../../start/framework/route-module#action) data from the most recent `POST` navigation form submission or `undefined` if there hasn't been one.
1330
1331
*
1331
1332
* @example
1332
1333
* import { Form, useActionData } from "react-router";
@@ -1351,7 +1352,7 @@ export function useRouteLoaderData<T = any>(
1351
1352
* @category Hooks
1352
1353
* @mode framework
1353
1354
* @mode data
1354
-
* @returns The data returned from the route's action function, or undefined if no action has been called
1355
+
* @returns The data returned from the route's [`action`](../../start/framework/route-module#action) function, or `undefined` if no `action` has been called
* @returns The error that was thrown during route loading, action execution, or rendering
1382
+
* @returns The error that was thrown during route [loading](../../start/framework/route-module#loader), [`action`](../../start/framework/route-module#action) execution, or rendering
1382
1383
*/
1383
1384
exportfunctionuseRouteError(): unknown{
1384
1385
leterror=React.useContext(RouteErrorContext);
@@ -1413,7 +1414,7 @@ export function useRouteError(): unknown {
1413
1414
* @category Hooks
1414
1415
* @mode framework
1415
1416
* @mode data
1416
-
* @returns The resolved value from the nearest Await component
1417
+
* @returns The resolved value from the nearest {@linkAwait} component
1417
1418
*/
1418
1419
exportfunctionuseAsyncValue(): unknown{
1419
1420
letvalue=React.useContext(AwaitContext);
@@ -1443,7 +1444,7 @@ export function useAsyncValue(): unknown {
1443
1444
* @category Hooks
1444
1445
* @mode framework
1445
1446
* @mode data
1446
-
* @returns The error that was thrown in the nearest Await component
1447
+
* @returns The error that was thrown in the nearest {@linkAwait} component
1447
1448
*/
1448
1449
exportfunctionuseAsyncError(): unknown{
1449
1450
letvalue=React.useContext(AwaitContext);
@@ -1454,11 +1455,11 @@ let blockerId = 0;
1454
1455
1455
1456
/**
1456
1457
* Allow the application to block navigations within the SPA and present the
1457
-
* user a confirmation dialog to confirm the navigation. Mostly used to avoid
1458
-
* using half-filled form data. This does not handle hard-reloads or
1458
+
* user a confirmation dialog to confirm the navigation. Mostly used to avoid
1459
+
* using half-filled form data. This does not handle hard-reloads or
1459
1460
* cross-origin navigations.
1460
1461
*
1461
-
* The Blocker object returned by the hook has the following properties:
1462
+
* The {@linkBlocker} object returned by the hook has the following properties:
1462
1463
*
1463
1464
* - **`state`**
1464
1465
* - `unblocked` - the blocker is idle and has not prevented any navigation
@@ -1554,8 +1555,8 @@ let blockerId = 0;
1554
1555
* @category Hooks
1555
1556
* @mode framework
1556
1557
* @mode data
1557
-
* @param shouldBlock Either a boolean or a function returning a boolean which indicates whether the navigation should be blocked. The function format receives a single object parameter containing the `currentLocation`, `nextLocation`, and `historyAction` of the potential navigation.
1558
-
* @returns A blocker object with state and reset functionality
1558
+
* @param shouldBlock Either a boolean or a function returning a boolean which indicates whether the navigation should be blocked. The function format receives a single object parameter containing the `currentLocation`, `nextLocation`, and `historyAction` of the potential navigation.
1559
+
* @returns A {@link Blocker} object with state and reset functionality
0 commit comments