Skip to content

Commit 055ba50

Browse files
authored
docs(router): update NotFoundError type (#4866)
- Mark the `global` property of `NotFoundError` as deprecated - Add a description for `headers` - Sort the properties in order Signed-off-by: leesb971204 <[email protected]>
1 parent ffec133 commit 055ba50

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

docs/router/framework/react/api/router/NotFoundErrorType.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,40 @@ export type NotFoundError = {
1111
data?: any
1212
throw?: boolean
1313
routeId?: string
14+
headers?: HeadersInit
1415
}
1516
```
1617
1718
## NotFoundError properties
1819
1920
The `NotFoundError` object accepts/contains the following properties:
2021
22+
### `global` property (⚠️ deprecated, use `routeId: rootRouteId` instead)
23+
24+
- Type: `boolean`
25+
- Optional - `default: false`
26+
- If true, the not-found error will be handled by the `notFoundComponent` of the root route instead of bubbling up from the route that threw it. This has the same behavior as importing the root route and calling `RootRoute.notFound()`.
27+
2128
### `data` property
2229
2330
- Type: `any`
2431
- Optional
2532
- Custom data that is passed into to `notFoundComponent` when the not-found error is handled
2633
27-
### `global` property
34+
### `throw` property
2835
2936
- Type: `boolean`
3037
- Optional - `default: false`
31-
- If true, the not-found error will be handled by the `notFoundComponent` of the root route instead of bubbling up from the route that threw it. This has the same behavior as importing the root route and calling `RootRoute.notFound()`.
38+
- If provided, will throw the not-found object instead of returning it. This can be useful in places where `throwing` in a function might cause it to have a return type of `never`. In that case, you can use `notFound({ throw: true })` to throw the not-found object instead of returning it.
3239
3340
### `route` property
3441
3542
- Type: `string`
3643
- Optional
3744
- The ID of the route that will attempt to handle the not-found error. If the route does not have a `notFoundComponent`, the error will bubble up to the parent route (and be handled by the root route if necessary). By default, TanStack Router will attempt to handle the not-found error with the route that threw it.
3845
39-
### `throw` property
46+
### `headers` property
4047
41-
- Type: `boolean`
42-
- Optional - `default: false`
43-
- If provided, will throw the not-found object instead of returning it. This can be useful in places where `throwing` in a function might cause it to have a return type of `never`. In that case, you can use `notFound({ throw: true })` to throw the not-found object instead of returning it.
48+
- Type: `HeadersInit`
49+
- Optional
50+
- HTTP headers to be included when the not-found error is handled on the server side.

0 commit comments

Comments
 (0)