@tanstack/react-router 0.0.1-beta.35 → 0.0.1-beta.37
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 +8 -9
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +8 -9
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +50 -50
- package/build/umd/index.development.js +103 -94
- 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/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.
|
|
4
|
+
"version": "0.0.1-beta.37",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router/",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@babel/runtime": "^7.16.7",
|
|
44
|
-
"@tanstack/router-core": "0.0.1-beta.
|
|
44
|
+
"@tanstack/router-core": "0.0.1-beta.36",
|
|
45
45
|
"use-sync-external-store": "^1.2.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
package/src/index.tsx
CHANGED
|
@@ -424,13 +424,10 @@ export function createReactRouter<
|
|
|
424
424
|
useMatch: (routeId, opts) => {
|
|
425
425
|
useRouterSubscription(router)
|
|
426
426
|
|
|
427
|
-
invariant(
|
|
428
|
-
routeId !== rootRouteId,
|
|
429
|
-
`"${rootRouteId}" cannot be used with useMatch! Did you mean to useRoute("${rootRouteId}")?`,
|
|
430
|
-
)
|
|
431
|
-
|
|
432
427
|
const nearestMatch = useNearestMatch()
|
|
433
|
-
const match = router.state.
|
|
428
|
+
const match = router.state.currentMatches.find(
|
|
429
|
+
(d) => d.routeId === routeId,
|
|
430
|
+
)
|
|
434
431
|
|
|
435
432
|
if (opts?.strict ?? true) {
|
|
436
433
|
invariant(
|
|
@@ -504,7 +501,7 @@ export function RouterProvider<
|
|
|
504
501
|
return (
|
|
505
502
|
<>
|
|
506
503
|
<routerContext.Provider value={{ router: router as any }}>
|
|
507
|
-
<MatchesProvider value={[undefined!, ...router.state.
|
|
504
|
+
<MatchesProvider value={[undefined!, ...router.state.currentMatches]}>
|
|
508
505
|
<Outlet />
|
|
509
506
|
</MatchesProvider>
|
|
510
507
|
</routerContext.Provider>
|
|
@@ -569,7 +566,7 @@ export function useRoute<
|
|
|
569
566
|
export function useSearch<
|
|
570
567
|
TId extends keyof RegisteredAllRouteInfo['routeInfoById'] = keyof RegisteredAllRouteInfo['routeInfoById'],
|
|
571
568
|
>(_routeId?: TId): RegisteredAllRouteInfo['fullSearchSchema'] {
|
|
572
|
-
return useRouter().state.
|
|
569
|
+
return useRouter().state.currentLocation.search
|
|
573
570
|
}
|
|
574
571
|
|
|
575
572
|
export function linkProps<TTo extends string = '.'>(
|
|
@@ -695,10 +692,10 @@ function CatchBoundaryInner(props: {
|
|
|
695
692
|
|
|
696
693
|
React.useEffect(() => {
|
|
697
694
|
if (activeErrorState) {
|
|
698
|
-
let prevKey = router.state.
|
|
695
|
+
let prevKey = router.state.currentLocation.key
|
|
699
696
|
return router.subscribe(() => {
|
|
700
|
-
if (router.state.
|
|
701
|
-
prevKey = router.state.
|
|
697
|
+
if (router.state.currentLocation.key !== prevKey) {
|
|
698
|
+
prevKey = router.state.currentLocation.key
|
|
702
699
|
setActiveErrorState({} as any)
|
|
703
700
|
}
|
|
704
701
|
})
|
|
@@ -758,12 +755,12 @@ export function usePrompt(message: string, when: boolean | any): void {
|
|
|
758
755
|
unblock()
|
|
759
756
|
transition.retry()
|
|
760
757
|
} else {
|
|
761
|
-
router.state.
|
|
758
|
+
router.state.currentLocation.pathname = window.location.pathname
|
|
762
759
|
}
|
|
763
760
|
})
|
|
764
761
|
|
|
765
762
|
return unblock
|
|
766
|
-
}, [when,
|
|
763
|
+
}, [when, message])
|
|
767
764
|
}
|
|
768
765
|
|
|
769
766
|
export function Prompt({ message, when, children }: PromptProps) {
|