@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.36",
4
+ "version": "0.0.1-beta.38",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router/",
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> {