@tanstack/react-router 1.22.1 → 1.22.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.22.1",
3
+ "version": "1.22.3",
4
4
  "description": "",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/Matches.tsx CHANGED
@@ -132,9 +132,7 @@ export function Match({ matchId }: { matchId: string }) {
132
132
  const pendingElement = PendingComponent ? <PendingComponent /> : null
133
133
 
134
134
  const routeErrorComponent =
135
- route.options.errorComponent ??
136
- router.options.defaultErrorComponent ??
137
- ErrorComponent
135
+ route.options.errorComponent ?? router.options.defaultErrorComponent
138
136
 
139
137
  const routeNotFoundComponent = route.isRoot
140
138
  ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
@@ -164,7 +162,7 @@ export function Match({ matchId }: { matchId: string }) {
164
162
  <ResolvedSuspenseBoundary fallback={pendingElement}>
165
163
  <ResolvedCatchBoundary
166
164
  getResetKey={() => router.state.resolvedLocation.state?.key!}
167
- errorComponent={routeErrorComponent}
165
+ errorComponent={routeErrorComponent ?? ErrorComponent}
168
166
  onCatch={(error) => {
169
167
  // Forward not found errors (we don't want to show the error component for these)
170
168
  if (isNotFound(error)) throw error
@@ -472,40 +470,8 @@ export function useMatch<
472
470
  select?: (match: TRouteMatchState) => TSelected
473
471
  },
474
472
  ): TSelected {
475
- const router = useRouter()
476
473
  const nearestMatchId = React.useContext(matchContext)
477
474
 
478
- const nearestMatchRouteId = getRenderedMatches(router.state).find(
479
- (d) => d.id === nearestMatchId,
480
- )?.routeId
481
-
482
- const strict = opts?.strict ?? true
483
-
484
- const matchRouteId = (() => {
485
- const matches = getRenderedMatches(router.state)
486
- const match = opts?.from
487
- ? matches.find((d) => d.routeId === opts?.from)
488
- : matches.find((d) => d.id === nearestMatchId)
489
- return match?.routeId
490
- })()
491
-
492
- if (strict) {
493
- invariant(
494
- matchRouteId,
495
- `No match found for route '${opts?.from}' while rendering the '${nearestMatchRouteId}' route. Did you mean to pass '{ strict: false }' instead?`,
496
- )
497
- invariant(
498
- nearestMatchRouteId == matchRouteId,
499
- `useMatch("${
500
- matchRouteId as string
501
- }") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch("${
502
- matchRouteId as string
503
- }", { strict: false })' or 'useRoute("${
504
- matchRouteId as string
505
- }")' instead?`,
506
- )
507
- }
508
-
509
475
  const matchSelection = useRouterState({
510
476
  select: (state) => {
511
477
  const match = getRenderedMatches(state).find((d) =>
@@ -658,6 +624,9 @@ export function defaultDeserializeError(serializedData: Record<string, any>) {
658
624
  if ('name' in serializedData && 'message' in serializedData) {
659
625
  const error = new Error(serializedData.message)
660
626
  error.name = serializedData.name
627
+ if (process.env.NODE_ENV === 'development') {
628
+ error.stack = serializedData.stack
629
+ }
661
630
  return error
662
631
  }
663
632
 
package/src/router.ts CHANGED
@@ -2074,12 +2074,19 @@ export function getInitialRouterState(
2074
2074
  }
2075
2075
 
2076
2076
  export function defaultSerializeError(err: unknown) {
2077
- if (err instanceof Error)
2078
- return {
2077
+ if (err instanceof Error) {
2078
+ const obj = {
2079
2079
  name: err.name,
2080
2080
  message: err.message,
2081
2081
  }
2082
2082
 
2083
+ if (process.env.NODE_ENV === 'development') {
2084
+ ;(obj as any).stack = err.stack
2085
+ }
2086
+
2087
+ return obj
2088
+ }
2089
+
2083
2090
  return {
2084
2091
  data: err,
2085
2092
  }