@tanstack/react-router 1.45.3 → 1.45.4

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/Matches.tsx CHANGED
@@ -68,6 +68,7 @@ export interface RouteMatch<
68
68
  globalNotFound?: boolean
69
69
  staticData: StaticDataRouteOption
70
70
  minPendingPromise?: ControlledPromise<void>
71
+ pendingTimeout?: ReturnType<typeof setTimeout>
71
72
  }
72
73
 
73
74
  export type MakeRouteMatch<
@@ -185,6 +186,10 @@ export type UseMatchRouteOptions<
185
186
  export function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {
186
187
  const router = useRouter()
187
188
 
189
+ useRouterState({
190
+ select: (s) => [s.location.href, s.resolvedLocation.href, s.status],
191
+ })
192
+
188
193
  return React.useCallback(
189
194
  <
190
195
  TFrom extends RoutePaths<TRouter['routeTree']> | string = string,
package/src/router.ts CHANGED
@@ -1126,7 +1126,12 @@ export class Router<
1126
1126
  }
1127
1127
 
1128
1128
  cancelMatch = (id: string) => {
1129
- this.getMatch(id)?.abortController.abort()
1129
+ const match = this.getMatch(id)
1130
+
1131
+ if (!match) return
1132
+
1133
+ match.abortController.abort()
1134
+ clearTimeout(match.pendingTimeout)
1130
1135
  }
1131
1136
 
1132
1137
  cancelMatches = () => {
@@ -1865,10 +1870,12 @@ export class Router<
1865
1870
  this.options.defaultPendingComponent)
1866
1871
  )
1867
1872
 
1873
+ let pendingTimeout: ReturnType<typeof setTimeout>
1874
+
1868
1875
  if (shouldPending) {
1869
1876
  // If we might show a pending component, we need to wait for the
1870
1877
  // pending promise to resolve before we start showing that state
1871
- setTimeout(() => {
1878
+ pendingTimeout = setTimeout(() => {
1872
1879
  try {
1873
1880
  // Update the match and prematurely resolve the loadMatches promise so that
1874
1881
  // the pending component can start rendering
@@ -1899,6 +1906,7 @@ export class Router<
1899
1906
  ),
1900
1907
  context: replaceEqualDeep(prev.context, parentContext),
1901
1908
  abortController,
1909
+ pendingTimeout,
1902
1910
  }))
1903
1911
 
1904
1912
  const { search, params, routeContext, cause } =