@tanstack/react-router 0.0.1-beta.36 → 0.0.1-beta.38
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/build/cjs/index.js +6 -2
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +7 -4
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +48 -48
- package/build/types/index.d.ts +3 -2
- package/build/umd/index.development.js +6 -2
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +6 -8
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
RegisteredRouter,
|
|
12
12
|
RouterState,
|
|
13
13
|
ToIdOption,
|
|
14
|
+
last,
|
|
14
15
|
} from '@tanstack/router-core'
|
|
15
16
|
import {
|
|
16
17
|
warning,
|
|
@@ -424,11 +425,6 @@ export function createReactRouter<
|
|
|
424
425
|
useMatch: (routeId, opts) => {
|
|
425
426
|
useRouterSubscription(router)
|
|
426
427
|
|
|
427
|
-
invariant(
|
|
428
|
-
routeId !== rootRouteId,
|
|
429
|
-
`"${rootRouteId}" cannot be used with useMatch! Did you mean to useRoute("${rootRouteId}")?`,
|
|
430
|
-
)
|
|
431
|
-
|
|
432
428
|
const nearestMatch = useNearestMatch()
|
|
433
429
|
const match = router.state.currentMatches.find(
|
|
434
430
|
(d) => d.routeId === routeId,
|
|
@@ -568,12 +564,14 @@ export function useRoute<
|
|
|
568
564
|
return router.useRoute(routeId as any) as any
|
|
569
565
|
}
|
|
570
566
|
|
|
571
|
-
export function useSearch
|
|
572
|
-
TId extends keyof RegisteredAllRouteInfo['routeInfoById'] = keyof RegisteredAllRouteInfo['routeInfoById'],
|
|
573
|
-
>(_routeId?: TId): RegisteredAllRouteInfo['fullSearchSchema'] {
|
|
567
|
+
export function useSearch(): RegisteredAllRouteInfo['fullSearchSchema'] {
|
|
574
568
|
return useRouter().state.currentLocation.search
|
|
575
569
|
}
|
|
576
570
|
|
|
571
|
+
export function useParams(): RegisteredAllRouteInfo['allParams'] {
|
|
572
|
+
return last(useRouter().state.currentMatches)?.params as any
|
|
573
|
+
}
|
|
574
|
+
|
|
577
575
|
export function linkProps<TTo extends string = '.'>(
|
|
578
576
|
props: MakeLinkPropsOptions<RegisteredAllRouteInfo, '/', TTo>,
|
|
579
577
|
): React.AnchorHTMLAttributes<HTMLAnchorElement> {
|