@tanstack/react-router 1.121.41 → 1.123.0

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.
@@ -1793,11 +1793,12 @@ Navigates to a new location.
1793
1793
 
1794
1794
  Invalidates route matches by forcing their \`beforeLoad\` and \`load\` functions to be called again.
1795
1795
 
1796
- - Type: \`(opts?: {filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean, sync?: boolean}) => Promise<void>\`
1796
+ - Type: \`(opts?: {filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean, sync?: boolean, forcePending?: boolean }) => Promise<void>\`
1797
1797
  - This is useful any time your loader data might be out of date or stale. For example, if you have a route that displays a list of posts, and you have a loader function that fetches the list of posts from an API, you might want to invalidate the route matches for that route any time a new post is created so that the list of posts is always up-to-date.
1798
1798
  - if \`filter\` is not supplied, all matches will be invalidated
1799
1799
  - if \`filter\` is supplied, only matches for which \`filter\` returns \`true\` will be invalidated.
1800
1800
  - if \`sync\` is true, the promise returned by this function will only resolve once all loaders have finished.
1801
+ - if \`forcePending\` is true, the invalidated matches will be put into \`'pending'\` state regardless whether they are in \`'error'\` state or not.
1801
1802
  - You might also want to invalidate the Router if you imperatively \`reset\` the router's \`CatchBoundary\` to trigger loaders again.
1802
1803
 
1803
1804
  ### \`.clearCache\` method
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.121.41",
3
+ "version": "1.123.0",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -80,8 +80,8 @@
80
80
  "tiny-invariant": "^1.3.3",
81
81
  "tiny-warning": "^1.0.3",
82
82
  "isbot": "^5.1.22",
83
- "@tanstack/router-core": "1.121.40",
84
- "@tanstack/history": "1.121.34"
83
+ "@tanstack/history": "1.121.34",
84
+ "@tanstack/router-core": "1.123.0"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@testing-library/jest-dom": "^6.6.3",
package/src/Match.tsx CHANGED
@@ -17,7 +17,11 @@ import { matchContext } from './matchContext'
17
17
  import { SafeFragment } from './SafeFragment'
18
18
  import { renderRouteNotFound } from './renderRouteNotFound'
19
19
  import { ScrollRestoration } from './scroll-restoration'
20
- import type { AnyRoute, ParsedLocation } from '@tanstack/router-core'
20
+ import type {
21
+ AnyRoute,
22
+ ParsedLocation,
23
+ RootRouteOptions,
24
+ } from '@tanstack/router-core'
21
25
 
22
26
  export const Match = React.memo(function MatchImpl({
23
27
  matchId,
@@ -80,8 +84,11 @@ export const Match = React.memo(function MatchImpl({
80
84
  },
81
85
  })
82
86
 
87
+ const ShellComponent = route.isRoot
88
+ ? ((route.options as RootRouteOptions).shellComponent ?? SafeFragment)
89
+ : SafeFragment
83
90
  return (
84
- <>
91
+ <ShellComponent>
85
92
  <matchContext.Provider value={matchId}>
86
93
  <ResolvedSuspenseBoundary fallback={pendingElement}>
87
94
  <ResolvedCatchBoundary
@@ -119,7 +126,7 @@ export const Match = React.memo(function MatchImpl({
119
126
  <ScrollRestoration />
120
127
  </>
121
128
  ) : null}
122
- </>
129
+ </ShellComponent>
123
130
  )
124
131
  })
125
132
 
package/src/Matches.tsx CHANGED
@@ -11,7 +11,6 @@ import type {
11
11
  StructuralSharingOption,
12
12
  ValidateSelected,
13
13
  } from './structuralSharing'
14
- import type { ReactNode } from './route'
15
14
  import type {
16
15
  AnyRouter,
17
16
  DeepPartial,
@@ -154,7 +153,7 @@ export type MakeMatchRouteOptions<
154
153
  TRouter['routeTree'],
155
154
  ResolveRelativePath<TFrom, NoInfer<TTo>>
156
155
  >['types']['allParams'],
157
- ) => ReactNode)
156
+ ) => React.ReactNode)
158
157
  | React.ReactNode
159
158
  }
160
159
 
package/src/index.tsx CHANGED
@@ -284,7 +284,6 @@ export {
284
284
  } from './route'
285
285
  export type {
286
286
  AnyRootRoute,
287
- ReactNode,
288
287
  SyncRouteComponent,
289
288
  AsyncRouteComponent,
290
289
  RouteComponent,
package/src/route.tsx CHANGED
@@ -54,6 +54,14 @@ declare module '@tanstack/router-core' {
54
54
  pendingComponent?: RouteComponent
55
55
  }
56
56
 
57
+ export interface RootRouteOptionsExtensions {
58
+ shellComponent?: ({
59
+ children,
60
+ }: {
61
+ children: React.ReactNode
62
+ }) => React.ReactNode
63
+ }
64
+
57
65
  export interface RouteExtensions<
58
66
  in out TId extends string,
59
67
  in out TFullPath extends string,
@@ -534,11 +542,9 @@ export function createRouteMask<
534
542
  return opts as any
535
543
  }
536
544
 
537
- export type ReactNode = any
538
-
539
545
  export type SyncRouteComponent<TProps> =
540
- | ((props: TProps) => ReactNode)
541
- | React.LazyExoticComponent<(props: TProps) => ReactNode>
546
+ | React.FC<TProps>
547
+ | React.LazyExoticComponent<(props: TProps) => React.ReactNode>
542
548
 
543
549
  export type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
544
550
  preload?: () => Promise<void>