@tanstack/react-router 1.160.0 → 1.161.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/dist/cjs/Asset.cjs +33 -19
- package/dist/cjs/Asset.cjs.map +1 -1
- package/dist/cjs/link.cjs +13 -5
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/esm/Asset.js +33 -19
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/link.js +13 -5
- package/dist/esm/link.js.map +1 -1
- package/dist/llms/rules/guide.d.ts +1 -1
- package/dist/llms/rules/guide.js +2821 -253
- package/dist/llms/rules/installation.d.ts +1 -1
- package/dist/llms/rules/installation.js +376 -357
- package/dist/llms/rules/routing.d.ts +1 -1
- package/dist/llms/rules/routing.js +436 -31
- package/dist/llms/rules/setup-and-architecture.d.ts +1 -1
- package/dist/llms/rules/setup-and-architecture.js +253 -90
- package/package.json +2 -2
- package/src/Asset.tsx +45 -17
- package/src/link.tsx +18 -9
package/src/link.tsx
CHANGED
|
@@ -376,10 +376,17 @@ export function useLinkProps<
|
|
|
376
376
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
377
377
|
const isHydrated = useHydrated()
|
|
378
378
|
|
|
379
|
-
// subscribe to search
|
|
379
|
+
// subscribe to path/search/hash/params to re-build location when they change
|
|
380
380
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
381
|
-
const
|
|
382
|
-
select: (s) =>
|
|
381
|
+
const currentLocationState = useRouterState({
|
|
382
|
+
select: (s) => {
|
|
383
|
+
const leaf = s.matches[s.matches.length - 1]
|
|
384
|
+
return {
|
|
385
|
+
search: leaf?.search,
|
|
386
|
+
hash: s.location.hash,
|
|
387
|
+
path: leaf?.pathname, // path + params
|
|
388
|
+
}
|
|
389
|
+
},
|
|
383
390
|
structuralSharing: true as any,
|
|
384
391
|
})
|
|
385
392
|
|
|
@@ -393,7 +400,7 @@ export function useLinkProps<
|
|
|
393
400
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
394
401
|
[
|
|
395
402
|
router,
|
|
396
|
-
|
|
403
|
+
currentLocationState,
|
|
397
404
|
from,
|
|
398
405
|
options._fromLocation,
|
|
399
406
|
options.hash,
|
|
@@ -556,11 +563,13 @@ export function useLinkProps<
|
|
|
556
563
|
|
|
557
564
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
558
565
|
const doPreload = React.useCallback(() => {
|
|
559
|
-
router
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
566
|
+
router
|
|
567
|
+
.preloadRoute({ ..._options, _builtLocation: next } as any)
|
|
568
|
+
.catch((err) => {
|
|
569
|
+
console.warn(err)
|
|
570
|
+
console.warn(preloadWarning)
|
|
571
|
+
})
|
|
572
|
+
}, [router, _options, next])
|
|
564
573
|
|
|
565
574
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
566
575
|
const preloadViewportIoCallback = React.useCallback(
|