@tanstack/react-router 1.139.0 → 1.139.3
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/dist/cjs/Transitioner.cjs +5 -2
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +0 -8
- package/dist/cjs/renderRouteNotFound.cjs +1 -1
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/renderRouteNotFound.d.cts +8 -0
- package/dist/cjs/useBlocker.cjs +11 -2
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/esm/Transitioner.js +5 -2
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +0 -8
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/renderRouteNotFound.d.ts +8 -0
- package/dist/esm/renderRouteNotFound.js +1 -1
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/useBlocker.js +11 -2
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/llms/rules/guide.d.ts +1 -1
- package/dist/llms/rules/guide.js +1 -1
- package/dist/llms/rules/routing.d.ts +1 -1
- package/dist/llms/rules/routing.js +2 -1
- package/dist/llms/rules/setup-and-architecture.d.ts +1 -1
- package/dist/llms/rules/setup-and-architecture.js +4 -2
- package/package.json +2 -2
- package/src/Transitioner.tsx +6 -4
- package/src/fileRoute.ts +0 -8
- package/src/renderRouteNotFound.tsx +9 -1
- package/src/useBlocker.tsx +16 -2
package/src/fileRoute.ts
CHANGED
|
@@ -89,14 +89,6 @@ export function createFileRoute<
|
|
|
89
89
|
@deprecated It's no longer recommended to use the `FileRoute` class directly.
|
|
90
90
|
Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
|
|
91
91
|
*/
|
|
92
|
-
/**
|
|
93
|
-
@deprecated It's no longer recommended to use the `FileRoute` class directly.
|
|
94
|
-
Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
|
|
95
|
-
*/
|
|
96
|
-
/**
|
|
97
|
-
@deprecated It's no longer recommended to use the `FileRoute` class directly.
|
|
98
|
-
Instead, use `createFileRoute('/path')(options)` to create a file route.
|
|
99
|
-
*/
|
|
100
92
|
export class FileRoute<
|
|
101
93
|
TFilePath extends keyof FileRoutesByPath,
|
|
102
94
|
TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],
|
|
@@ -3,6 +3,14 @@ import warning from 'tiny-warning'
|
|
|
3
3
|
import { DefaultGlobalNotFound } from './not-found'
|
|
4
4
|
import type { AnyRoute, AnyRouter } from '@tanstack/router-core'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Renders a not found component for a route when no matching route is found.
|
|
8
|
+
*
|
|
9
|
+
* @param router - The router instance containing the route configuration
|
|
10
|
+
* @param route - The route that triggered the not found state
|
|
11
|
+
* @param data - Additional data to pass to the not found component
|
|
12
|
+
* @returns The rendered not found component or a default fallback component
|
|
13
|
+
*/
|
|
6
14
|
export function renderRouteNotFound(
|
|
7
15
|
router: AnyRouter,
|
|
8
16
|
route: AnyRoute,
|
|
@@ -16,7 +24,7 @@ export function renderRouteNotFound(
|
|
|
16
24
|
if (process.env.NODE_ENV === 'development') {
|
|
17
25
|
warning(
|
|
18
26
|
route.options.notFoundComponent,
|
|
19
|
-
`A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<
|
|
27
|
+
`A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`,
|
|
20
28
|
)
|
|
21
29
|
}
|
|
22
30
|
|
package/src/useBlocker.tsx
CHANGED
|
@@ -179,20 +179,34 @@ export function useBlocker(
|
|
|
179
179
|
const parsedLocation = router.parseLocation(location)
|
|
180
180
|
const matchedRoutes = router.getMatchedRoutes(parsedLocation.pathname)
|
|
181
181
|
if (matchedRoutes.foundRoute === undefined) {
|
|
182
|
-
|
|
182
|
+
return {
|
|
183
|
+
routeId: '__notFound__',
|
|
184
|
+
fullPath: parsedLocation.pathname,
|
|
185
|
+
pathname: parsedLocation.pathname,
|
|
186
|
+
params: matchedRoutes.routeParams,
|
|
187
|
+
search: router.options.parseSearch(location.search),
|
|
188
|
+
}
|
|
183
189
|
}
|
|
190
|
+
|
|
184
191
|
return {
|
|
185
192
|
routeId: matchedRoutes.foundRoute.id,
|
|
186
193
|
fullPath: matchedRoutes.foundRoute.fullPath,
|
|
187
194
|
pathname: parsedLocation.pathname,
|
|
188
195
|
params: matchedRoutes.routeParams,
|
|
189
|
-
search:
|
|
196
|
+
search: router.options.parseSearch(location.search),
|
|
190
197
|
}
|
|
191
198
|
}
|
|
192
199
|
|
|
193
200
|
const current = getLocation(blockerFnArgs.currentLocation)
|
|
194
201
|
const next = getLocation(blockerFnArgs.nextLocation)
|
|
195
202
|
|
|
203
|
+
if (
|
|
204
|
+
current.routeId === '__notFound__' &&
|
|
205
|
+
next.routeId !== '__notFound__'
|
|
206
|
+
) {
|
|
207
|
+
return false
|
|
208
|
+
}
|
|
209
|
+
|
|
196
210
|
const shouldBlock = await shouldBlockFn({
|
|
197
211
|
action: blockerFnArgs.action,
|
|
198
212
|
current,
|