Skip to content

refactor: jsdoc and docs for RouteOptions #4317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/router/framework/react/api/router/RouteOptionsType.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ type loaderDeps = (opts: { search: TFullSearchSchema }) => Record<string, any>
- By default, path params are already used to uniquely identify a route match, so it's unnecessary to return these here.
- If your route match relies on search params for unique identification, it's required that you return them here so they can be made available in the `loader`'s `deps` argument.

### `preload` property

- Type: `boolean`
- Optional
- If `false`, this route will opt out of preloading.

### `staleTime` property

- Type: `number`
Expand All @@ -178,7 +184,14 @@ type loaderDeps = (opts: { search: TFullSearchSchema }) => Record<string, any>
- Type: `number`
- Optional
- Defaults to `routerOptions.defaultGcTime`, which defaults to 30 minutes.
- The amount of time in milliseconds that a route match's loader data will be kept in memory after a preload or it is no longer in use.
- The amount of time in milliseconds that a route match's loader data will be kept in memory after a preload or after it is no longer in use.

### `preloadGcTime` property

- Type: `number`
- Optional
- Defaults to `routerOptions.defaultPreloadGcTime`, which defaults to 30 minutes.
- The amount of time in milliseconds that a route match's loader data will be kept in memory after a preload.

### `shouldReload` property

Expand All @@ -192,6 +205,7 @@ type loaderDeps = (opts: { search: TFullSearchSchema }) => Record<string, any>

- Type: `boolean`
- Optional
- Defaults to `routerOptions.caseSensitive`, which defaults to `false`.
- If `true`, this route will be matched as case-sensitive.

### `wrapInSuspense` property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ The `RouterOptions` type accepts an object with the following properties and met
- Type: `number`
- Optional
- Defaults to `routerOptions.defaultGcTime`, which defaults to 30 minutes.
- The default `preloadGcTime` a route should use if no preloadGcTime is provided.
- The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.

### `defaultGcTime` property

Expand Down
27 changes: 27 additions & 0 deletions packages/react-router/src/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,36 @@ import type { LinkComponentRoute } from './link'

declare module '@tanstack/router-core' {
export interface UpdatableRouteOptionsExtensions {
/**
* The content to be rendered when the route is matched.
*
* @default Outlet
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#component-property)
*/
component?: RouteComponent
/**
* The content to be rendered when the route encounters an error.
*
* @default routerOptions.defaultErrorComponent
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#errorcomponent-property)
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
*/
errorComponent?: false | null | ErrorRouteComponent
/**
* The default `notFoundComponent` a route should use if no notFound component is provided.
*
* @default routerOptions.defaultNotFoundComponent
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#notfoundcomponent-property)
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#configuring-a-routes-notfoundcomponent)
*/
notFoundComponent?: NotFoundRouteComponent
/**
* The content to be rendered if and when the route is pending and has reached its pendingMs threshold.
*
* @default routerOptions.defaultPendingComponent
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#pendingcomponent-property)
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
*/
pendingComponent?: RouteComponent
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ declare module '@tanstack/router-core' {
*
* @default ErrorComponent
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#using-the-default-errorcomponent)
*/
defaultErrorComponent?: ErrorRouteComponent
/**
Expand Down
Loading