@tanstack/react-router 0.0.1-beta.74 → 0.0.1-beta.75
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 +12 -8
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +12 -8
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +57 -57
- package/build/types/index.d.ts +1 -1
- package/build/umd/index.development.js +31 -27
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +10 -13
package/src/index.tsx
CHANGED
|
@@ -343,7 +343,7 @@ export function RouterProvider<
|
|
|
343
343
|
>({ router, ...rest }: RouterProps<TRouteConfig, TRoutesInfo>) {
|
|
344
344
|
router.update(rest)
|
|
345
345
|
|
|
346
|
-
const currentMatches = useStore(router.
|
|
346
|
+
const currentMatches = useStore(router.__store, (s) => s.currentMatches)
|
|
347
347
|
|
|
348
348
|
React.useEffect(router.mount, [router])
|
|
349
349
|
|
|
@@ -370,17 +370,17 @@ export function useRouterContext(): RegisteredRouter {
|
|
|
370
370
|
const value = React.useContext(routerContext)
|
|
371
371
|
warning(value, 'useRouter must be used inside a <Router> component!')
|
|
372
372
|
|
|
373
|
-
useStore(value.router.
|
|
373
|
+
useStore(value.router.__store)
|
|
374
374
|
|
|
375
375
|
return value.router
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
export function useRouter<T = RouterStore>(
|
|
379
|
-
track?: (state: Router['
|
|
379
|
+
track?: (state: Router['__store']) => T,
|
|
380
380
|
shallow?: boolean,
|
|
381
381
|
): RegisteredRouter {
|
|
382
382
|
const router = useRouterContext()
|
|
383
|
-
useStore(router.
|
|
383
|
+
useStore(router.__store, track as any, shallow)
|
|
384
384
|
return router
|
|
385
385
|
}
|
|
386
386
|
|
|
@@ -430,7 +430,7 @@ export function useMatch<
|
|
|
430
430
|
}
|
|
431
431
|
|
|
432
432
|
useStore(
|
|
433
|
-
match!.
|
|
433
|
+
match!.__store as any,
|
|
434
434
|
(d) => opts?.track?.(match as any) ?? match,
|
|
435
435
|
opts?.shallow,
|
|
436
436
|
)
|
|
@@ -464,12 +464,9 @@ export function useSearch<
|
|
|
464
464
|
strict?: TStrict
|
|
465
465
|
track?: (search: TSearch) => TSelected
|
|
466
466
|
}): TStrict extends true ? TSelected : TSelected | undefined {
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
(d: any) => opts?.track?.(d.search) ?? d.search,
|
|
471
|
-
true,
|
|
472
|
-
)
|
|
467
|
+
const { track, ...matchOpts } = opts as any
|
|
468
|
+
const match = useMatch(matchOpts)
|
|
469
|
+
useStore(match.__store, (d: any) => opts?.track?.(d.search) ?? d.search, true)
|
|
473
470
|
|
|
474
471
|
return (match as unknown as RouteMatch).state.search as any
|
|
475
472
|
}
|
|
@@ -485,7 +482,7 @@ export function useParams<
|
|
|
485
482
|
}): TSelected {
|
|
486
483
|
const router = useRouterContext()
|
|
487
484
|
useStore(
|
|
488
|
-
router.
|
|
485
|
+
router.__store,
|
|
489
486
|
(d) => {
|
|
490
487
|
const params = last(d.currentMatches)?.params as any
|
|
491
488
|
return opts?.track?.(params) ?? params
|
|
@@ -571,7 +568,7 @@ function SubOutlet({
|
|
|
571
568
|
match: RouteMatch
|
|
572
569
|
}) {
|
|
573
570
|
const router = useRouterContext()
|
|
574
|
-
useStore(match!.
|
|
571
|
+
useStore(match!.__store, (store) => [store.status, store.error], true)
|
|
575
572
|
|
|
576
573
|
const defaultPending = React.useCallback(() => null, [])
|
|
577
574
|
|