@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/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: any) => void
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: unknown
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