@tanstack/react-router 1.57.17 → 1.58.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.57.17",
3
+ "version": "1.58.1",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -66,7 +66,7 @@
66
66
  "peerDependencies": {
67
67
  "react": ">=18",
68
68
  "react-dom": ">=18",
69
- "@tanstack/router-generator": "1.57.15"
69
+ "@tanstack/router-generator": "1.58.1"
70
70
  },
71
71
  "peerDependenciesMeta": {
72
72
  "@tanstack/router-generator": {
package/src/router.ts CHANGED
@@ -532,6 +532,15 @@ export const componentTypes = [
532
532
  'notFoundComponent',
533
533
  ] as const
534
534
 
535
+ function routeNeedsPreload(route: AnyRoute) {
536
+ for (const componentType of componentTypes) {
537
+ if ((route.options[componentType] as any)?.preload) {
538
+ return true
539
+ }
540
+ }
541
+ return false
542
+ }
543
+
535
544
  export type RouterEvents = {
536
545
  onBeforeNavigate: {
537
546
  type: 'onBeforeNavigate'
@@ -1179,7 +1188,10 @@ export class Router<
1179
1188
  }
1180
1189
  } else {
1181
1190
  const status =
1182
- route.options.loader || route.options.beforeLoad || route.lazyFn
1191
+ route.options.loader ||
1192
+ route.options.beforeLoad ||
1193
+ route.lazyFn ||
1194
+ routeNeedsPreload(route)
1183
1195
  ? 'pending'
1184
1196
  : 'success'
1185
1197
 
@@ -1326,7 +1338,7 @@ export class Router<
1326
1338
  'Could not find match for from: ' + dest.from,
1327
1339
  )
1328
1340
 
1329
- const fromSearch = this.state.pendingMatches
1341
+ const fromSearch = this.state.pendingMatches?.length
1330
1342
  ? last(this.state.pendingMatches)?.search
1331
1343
  : last(fromMatches)?.search || this.latestLocation.search
1332
1344