@tanstack/react-router 1.31.27 → 1.31.29

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
@@ -104,11 +104,15 @@ export function Matches() {
104
104
  <router.options.defaultPendingComponent />
105
105
  ) : null
106
106
 
107
+ const ResolvedSuspense = !router.state.matches.length
108
+ ? React.Suspense
109
+ : SafeFragment
110
+
107
111
  const inner = (
108
- <React.Suspense fallback={pendingElement}>
112
+ <ResolvedSuspense fallback={pendingElement}>
109
113
  <Transitioner />
110
114
  <MatchesInner />
111
- </React.Suspense>
115
+ </ResolvedSuspense>
112
116
  )
113
117
 
114
118
  return router.options.InnerWrap ? (
@@ -180,11 +184,10 @@ export function Match({ matchId }: { matchId: string }) {
180
184
  : route.options.notFoundComponent
181
185
 
182
186
  const ResolvedSuspenseBoundary =
183
- route.options.wrapInSuspense ??
184
- PendingComponent ??
185
- route.options.component?.preload ??
186
- route.options.pendingComponent?.preload ??
187
- (route.options.errorComponent as any)?.preload
187
+ !route.isRoot &&
188
+ (route.options.wrapInSuspense ??
189
+ PendingComponent ??
190
+ (route.options.errorComponent as any)?.preload)
188
191
  ? React.Suspense
189
192
  : SafeFragment
190
193
 
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react'
2
- import { ControlledPromise, createControlledPromise } from './utils'
3
2
  import type { AsyncRouteComponent } from './route'
4
3
 
5
4
  // If the load fails due to module not found, it may mean a new version of
package/src/route.ts CHANGED
@@ -1021,30 +1021,7 @@ export type RootRouteOptions<
1021
1021
  | 'caseSensitive'
1022
1022
  | 'parseParams'
1023
1023
  | 'stringifyParams'
1024
- > & {
1025
- /**
1026
- * @description When using SSR and the <StartServer> component, this component, if supplied will wrap
1027
- * the entire application during SSR and provide a <div id='root'> node for client-side hydration.
1028
- * The shellComponent is non-reactive and will not be re-rendered on the client.
1029
- * When used, it's common to render <html>, <head>, and <body> tags here.
1030
- *
1031
- * If your shell needs to be reactive, consider rendering your <html>, <head>, and <body> tags your
1032
- * root route's component, but be VERY cautious as attempting to hydrate/render over the entire
1033
- * document can and likely will lead to hydration mismatches.
1034
- *
1035
- * NOTE: Version 19 of React will allow using native <html>, <head>, and <body> tags in
1036
- * your components, which will automatically be hoisted and kept in sync with both server
1037
- * and client-side rendering. When 19 is released, this prop will be deprecated.
1038
- */
1039
- shellComponent?: (props: { children: React.ReactNode }) => JSX.Element
1040
- /**
1041
- * @description It's suggested to first use the `meta` option in the root route and sub routes to
1042
- * add meta tags. However, it may not be possible to add all types of meta tags using the `meta` option, like
1043
- * "base", for example, or you may want to read from router state/context to conditionally add meta tags in a
1044
- * component context.
1045
- **/
1046
- metaComponent?: (props: { children: React.ReactNode }) => JSX.Element
1047
- }
1024
+ >
1048
1025
 
1049
1026
  export function createRootRouteWithContext<TRouterContext extends {}>() {
1050
1027
  return <
package/src/router.ts CHANGED
@@ -11,7 +11,6 @@ import {
11
11
  functionalUpdate,
12
12
  last,
13
13
  pick,
14
- removeLayoutSegments,
15
14
  replaceEqualDeep,
16
15
  } from './utils'
17
16
  import { getRouteMatch } from './RouterProvider'
@@ -494,8 +493,7 @@ export class Router<
494
493
  scores: Array<number>
495
494
  }> = []
496
495
 
497
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
498
- const routes = Object.values(this.routesById) as Array<AnyRoute>
496
+ const routes: Array<AnyRoute> = Object.values(this.routesById)
499
497
 
500
498
  routes.forEach((d, i) => {
501
499
  if (d.isRoot || !d.path) {
@@ -937,17 +935,16 @@ export class Router<
937
935
  fromMatches.find((e) => e.routeId === d.routeId),
938
936
  )
939
937
 
940
- const fromRouteByFromPath = stayingMatches?.find(
941
- (d) => d.pathname === fromPath,
942
- )
938
+ const fromRouteByFromPathRouteId =
939
+ this.routesById[
940
+ stayingMatches?.find((d) => d.pathname === fromPath)?.routeId
941
+ ]
943
942
 
944
943
  let pathname = dest.to
945
944
  ? this.resolvePathWithBase(fromPath, `${dest.to}`)
946
945
  : this.resolvePathWithBase(
947
946
  fromPath,
948
- fromRouteByFromPath
949
- ? removeLayoutSegments(fromRouteByFromPath.routeId)
950
- : fromPath,
947
+ fromRouteByFromPathRouteId?.to ?? fromPath,
951
948
  )
952
949
 
953
950
  const prevParams = { ...last(fromMatches)?.params }
@@ -1822,7 +1819,11 @@ export class Router<
1822
1819
  match.status === 'success' &&
1823
1820
  (match.invalid || (shouldReload ?? age > staleAge))
1824
1821
  ) {
1825
- fetchWithRedirectAndNotFound()
1822
+ ;(async () => {
1823
+ try {
1824
+ await fetchWithRedirectAndNotFound()
1825
+ } catch (err) {}
1826
+ })()
1826
1827
  return
1827
1828
  }
1828
1829
 
package/src/utils.ts CHANGED
@@ -339,20 +339,6 @@ export function createControlledPromise<T>(onResolve?: () => void) {
339
339
  return controlledPromise
340
340
  }
341
341
 
342
- /**
343
- * Removes all segments from a given path that start with an underscore ('_').
344
- *
345
- * @param {string} routePath - The path from which to remove segments. Defaults to '/'.
346
- * @returns {string} The path with all underscore-prefixed segments removed.
347
- * @example
348
- * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'
349
- */
350
- export function removeLayoutSegments(routePath: string): string {
351
- const segments = routePath.split('/')
352
- const newSegments = segments.filter((segment) => !segment.startsWith('_'))
353
- return newSegments.join('/')
354
- }
355
-
356
342
  /**
357
343
  * Taken from https://www.developerway.com/posts/implementing-advanced-use-previous-hook#part3
358
344
  */