@tanstack/react-router 1.4.5 → 1.4.6

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
3
  "author": "Tanner Linsley",
4
- "version": "1.4.5",
4
+ "version": "1.4.6",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -44,7 +44,7 @@
44
44
  "@tanstack/store": "^0.1.3",
45
45
  "tiny-invariant": "^1.3.1",
46
46
  "tiny-warning": "^1.0.3",
47
- "@tanstack/history": "1.4.5"
47
+ "@tanstack/history": "1.4.6"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "rollup --config rollup.config.js"
package/src/Matches.tsx CHANGED
@@ -45,6 +45,7 @@ export interface RouteMatch<
45
45
  loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']
46
46
  preload: boolean
47
47
  invalid: boolean
48
+ pendingPromise?: Promise<void>
48
49
  }
49
50
 
50
51
  export type AnyRouteMatch = RouteMatch<any, any>
package/src/router.ts CHANGED
@@ -1058,6 +1058,12 @@ export class Router<
1058
1058
  const parentContext =
1059
1059
  parentMatch?.context ?? this.options.context ?? {}
1060
1060
 
1061
+ const pendingMs =
1062
+ route.options.pendingMs ?? this.options.defaultPendingMs
1063
+ const pendingPromise = new Promise<void>((r) =>
1064
+ setTimeout(r, pendingMs),
1065
+ )
1066
+
1061
1067
  const beforeLoadContext =
1062
1068
  (await route.options.beforeLoad?.({
1063
1069
  search: match.search,
@@ -1090,6 +1096,7 @@ export class Router<
1090
1096
  ),
1091
1097
  context: replaceEqualDeep(match.context, context),
1092
1098
  abortController,
1099
+ pendingPromise,
1093
1100
  }
1094
1101
  } catch (err) {
1095
1102
  handleErrorAndRedirect(err, 'BEFORE_LOAD')
@@ -1274,7 +1281,7 @@ export class Router<
1274
1281
  // If we need to potentially show the pending component,
1275
1282
  // start a timer to show it after the pendingMs
1276
1283
  if (shouldPending) {
1277
- new Promise((r) => setTimeout(r, pendingMs)).then(async () => {
1284
+ match.pendingPromise?.then(async () => {
1278
1285
  if ((latestPromise = checkLatest())) return latestPromise
1279
1286
 
1280
1287
  didShowPending = true