@tanstack/react-router 1.130.8 → 1.130.10

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.
@@ -168,9 +168,9 @@ This approach can also be used in conjunction with Pathless or Layout Route to p
168
168
 
169
169
  For detailed, step-by-step implementation guides, see:
170
170
 
171
- - [How to Set Up Basic Authentication](../how-to/setup-authentication.md) - Complete setup with React Context and protected routes
172
- - [How to Integrate Authentication Providers](../how-to/setup-auth-providers.md) - Use Auth0, Clerk, or Supabase
173
- - [How to Set Up Role-Based Access Control](../how-to/setup-rbac.md) - Implement permissions and role-based routing
171
+ - [How to Set Up Basic Authentication](../../how-to/setup-authentication.md) - Complete setup with React Context and protected routes
172
+ - [How to Integrate Authentication Providers](../../how-to/setup-auth-providers.md) - Use Auth0, Clerk, or Supabase
173
+ - [How to Set Up Role-Based Access Control](../../how-to/setup-rbac.md) - Implement permissions and role-based routing
174
174
 
175
175
  ## Examples
176
176
 
@@ -1292,7 +1292,10 @@ export const Route = createFileRoute('/posts')({
1292
1292
  The \`loader\` function receives a single object with the following properties:
1293
1293
 
1294
1294
  - \`abortController\` - The route's abortController. Its signal is cancelled when the route is unloaded or when the Route is no longer relevant and the current invocation of the \`loader\` function becomes outdated.
1295
- - \`cause\` - The cause of the current route match, either \`enter\` or \`stay\`.
1295
+ - \`cause\` - The cause of the current route match. Can be either one of the following:
1296
+ - \`enter\` - When the route is matched and loaded after not being matched in the previous location.
1297
+ - \`preload\` - When the route is being preloaded.
1298
+ - \`stay\` - When the route is matched and loaded after being matched in the previous location.
1296
1299
  - \`context\` - The route's context object, which is a merged union of:
1297
1300
  - Parent route context
1298
1301
  - This route's context as provided by the \`beforeLoad\` option
@@ -1909,7 +1912,7 @@ TanStack Router is designed to run loaders in parallel and wait for all of them
1909
1912
 
1910
1913
  Deferred data loading is a pattern that allows the router to render the next location's critical data/markup while slower, non-critical route data is resolved in the background. This process works on both the client and server (via streaming) and is a great way to improve the perceived performance of your application.
1911
1914
 
1912
- If you are using a library like [TanStack Query](https://react-query.tanstack.com) or any other data fetching library, then deferred data loading works a bit differently. Skip ahead to the [Deferred Data Loading with External Libraries](#deferred-data-loading-with-external-libraries) section for more information.
1915
+ If you are using a library like [TanStack Query](https://tanstack.com/query/latest) or any other data fetching library, then deferred data loading works a bit differently. Skip ahead to the [Deferred Data Loading with External Libraries](#deferred-data-loading-with-external-libraries) section for more information.
1913
1916
 
1914
1917
  ## Deferred Data Loading with \`Await\`
1915
1918
 
@@ -2178,7 +2181,7 @@ To do this, you must:
2178
2181
 
2179
2182
  \`\`\`tsx
2180
2183
  export const Route = createRootRoute({
2181
- scripts: [
2184
+ scripts: () => [
2182
2185
  {
2183
2186
  children: 'console.log("Hello, world!")',
2184
2187
  },
@@ -2321,7 +2324,7 @@ export const Route = createFileRoute('/posts')({
2321
2324
 
2322
2325
  ### Error handling with TanStack Query
2323
2326
 
2324
- When an error occurs while using \`suspense\` with \`Tanstack Query\`, you'll need to let queries know that you want to try again when re-rendering. This can be done by using the \`reset\` function provided by the \`useQueryErrorResetBoundary\` hook. We can invoke this function in an effect as soon as the error component mounts. This will make sure that the query is reset and will try to fetch data again when the route component is rendered again. This will also cover cases where users navigate away from our route instead of clicking the \`retry\` button.
2327
+ When an error occurs while using \`suspense\` with \`TanStack Query\`, you'll need to let queries know that you want to try again when re-rendering. This can be done by using the \`reset\` function provided by the \`useQueryErrorResetBoundary\` hook. We can invoke this function in an effect as soon as the error component mounts. This will make sure that the query is reset and will try to fetch data again when the route component is rendered again. This will also cover cases where users navigate away from our route instead of clicking the \`retry\` button.
2325
2328
 
2326
2329
  \`\`\`tsx
2327
2330
  export const Route = createFileRoute('/')({
@@ -3034,6 +3037,30 @@ const link = (
3034
3037
 
3035
3038
  As seen above, it's common to provide the \`route.fullPath\` as the \`from\` route path. This is because the \`route.fullPath\` is a reference that will update if you refactor your application. However, sometimes it's not possible to import the route directly, in which case it's fine to provide the route path directly as a string. It will still get type-checked as per usual!
3036
3039
 
3040
+ ### Special relative paths: \`"."\` and \`".."\`
3041
+
3042
+ Quite often you might want to reload the current location, for example, to rerun the loaders on the current and/or parent routes, or maybe there was a change in search parameters. This can be achieved by specifying a \`to\` route path of \`"."\` which will reload the current location. This is only applicable to the current location, and hence any \`from\` route path specified is ignored.
3043
+
3044
+ Another common need is to navigate one route back relative to the current location or some other matched route in the current tree. By specifying a \`to\` route path of \`".."\` navigation will be resolved to either the first parent route preceding the current location or, if specified, preceding the \`"from"\` route path.
3045
+
3046
+ \`\`\`tsx
3047
+ export const Route = createFileRoute('/posts/$postId')({
3048
+ component: PostComponent,
3049
+ })
3050
+
3051
+ function PostComponent() {
3052
+ return (
3053
+ <div>
3054
+ <Link to=".">Reload the current route of /posts/$postId</Link>
3055
+ <Link to="..">Navigate to /posts</Link>
3056
+ <Link from="/posts" to="..">
3057
+ Navigate to root
3058
+ </Link>
3059
+ </div>
3060
+ )
3061
+ }
3062
+ \`\`\`
3063
+
3037
3064
  ### Search Param Links
3038
3065
 
3039
3066
  Search params are a great way to provide additional context to a route. For example, you might want to provide a search query to a search page:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.130.8",
3
+ "version": "1.130.10",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -80,7 +80,7 @@
80
80
  "tiny-invariant": "^1.3.3",
81
81
  "tiny-warning": "^1.0.3",
82
82
  "@tanstack/history": "1.129.7",
83
- "@tanstack/router-core": "1.130.8"
83
+ "@tanstack/router-core": "1.130.10"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@testing-library/jest-dom": "^6.6.3",