@tanstack/react-router 1.32.17 → 1.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/CatchBoundary.cjs +2 -4
- package/dist/cjs/CatchBoundary.cjs.map +1 -1
- package/dist/cjs/CatchBoundary.d.cts +5 -3
- package/dist/cjs/Matches.cjs +10 -6
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +1 -0
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/not-found.cjs +2 -2
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +2 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +2 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +2 -0
- package/dist/esm/CatchBoundary.d.ts +5 -3
- package/dist/esm/CatchBoundary.js +2 -4
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/Matches.js +10 -6
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +1 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/not-found.d.ts +2 -1
- package/dist/esm/not-found.js +2 -2
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/route.d.ts +2 -1
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +2 -0
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/CatchBoundary.tsx +14 -11
- package/src/Matches.tsx +9 -6
- package/src/index.tsx +1 -0
- package/src/not-found.tsx +4 -3
- package/src/route.ts +2 -1
- package/src/router.ts +2 -0
package/src/not-found.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { CatchBoundary } from './CatchBoundary'
|
|
|
4
4
|
import { useRouterState } from './useRouterState'
|
|
5
5
|
import type { RegisteredRouter } from './router'
|
|
6
6
|
import type { RouteIds } from './routeInfo'
|
|
7
|
+
import type { ErrorInfo } from 'react'
|
|
7
8
|
|
|
8
9
|
export type NotFoundError = {
|
|
9
10
|
/**
|
|
@@ -34,7 +35,7 @@ export function isNotFound(obj: any): obj is NotFoundError {
|
|
|
34
35
|
|
|
35
36
|
export function CatchNotFound(props: {
|
|
36
37
|
fallback?: (error: NotFoundError) => React.ReactElement
|
|
37
|
-
onCatch?: (error:
|
|
38
|
+
onCatch?: (error: Error, errorInfo: ErrorInfo) => void
|
|
38
39
|
children: React.ReactNode
|
|
39
40
|
}) {
|
|
40
41
|
// TODO: Some way for the user to programmatically reset the not-found boundary?
|
|
@@ -45,9 +46,9 @@ export function CatchNotFound(props: {
|
|
|
45
46
|
return (
|
|
46
47
|
<CatchBoundary
|
|
47
48
|
getResetKey={() => resetKey}
|
|
48
|
-
onCatch={(error) => {
|
|
49
|
+
onCatch={(error, errorInfo) => {
|
|
49
50
|
if (isNotFound(error)) {
|
|
50
|
-
props.onCatch?.(error)
|
|
51
|
+
props.onCatch?.(error, errorInfo)
|
|
51
52
|
} else {
|
|
52
53
|
throw error
|
|
53
54
|
}
|
package/src/route.ts
CHANGED
|
@@ -266,6 +266,7 @@ export type UpdatableRouteOptions<
|
|
|
266
266
|
// Filter functions that can manipulate search params *after* they are passed to links and navigate
|
|
267
267
|
// calls that match this route.
|
|
268
268
|
postSearchFilters?: Array<SearchFilter<TFullSearchSchema>>
|
|
269
|
+
onCatch?: (error: Error, errorInfo: React.ErrorInfo) => void
|
|
269
270
|
onError?: (err: any) => void
|
|
270
271
|
// These functions are called as route matches are loaded, stick around and leave the active
|
|
271
272
|
// matches
|
|
@@ -1281,7 +1282,7 @@ export type ErrorRouteProps = {
|
|
|
1281
1282
|
}
|
|
1282
1283
|
|
|
1283
1284
|
export type ErrorComponentProps = {
|
|
1284
|
-
error:
|
|
1285
|
+
error: Error
|
|
1285
1286
|
info?: { componentStack: string }
|
|
1286
1287
|
reset: () => void
|
|
1287
1288
|
}
|
package/src/router.ts
CHANGED
|
@@ -81,6 +81,7 @@ import type { NotFoundError } from './not-found'
|
|
|
81
81
|
import type { NavigateOptions, ResolveRelativePath, ToOptions } from './link'
|
|
82
82
|
import type { NoInfer } from '@tanstack/react-store'
|
|
83
83
|
import type { DeferredPromiseState } from './defer'
|
|
84
|
+
import type { ErrorInfo } from 'react'
|
|
84
85
|
|
|
85
86
|
//
|
|
86
87
|
|
|
@@ -138,6 +139,7 @@ export interface RouterOptions<
|
|
|
138
139
|
defaultStaleTime?: number
|
|
139
140
|
defaultPreloadStaleTime?: number
|
|
140
141
|
defaultPreloadGcTime?: number
|
|
142
|
+
defaultOnCatch?: (error: Error, errorInfo: ErrorInfo) => void
|
|
141
143
|
defaultViewTransition?: boolean
|
|
142
144
|
notFoundMode?: 'root' | 'fuzzy'
|
|
143
145
|
defaultGcTime?: number
|