@tanstack/react-router 0.0.1-beta.22 → 0.0.1-beta.24
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/react-router/src/index.js +9 -2
- package/build/cjs/react-router/src/index.js.map +1 -1
- package/build/cjs/router-core/build/esm/index.js +17 -12
- package/build/cjs/router-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +26 -15
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +29 -29
- package/build/types/index.d.ts +6 -2
- package/build/umd/index.development.js +26 -14
- 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 +2 -2
- package/src/index.tsx +18 -3
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.24",
|
|
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.24",
|
|
45
45
|
"use-sync-external-store": "^1.2.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
package/src/index.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
CheckId,
|
|
8
8
|
rootRouteId,
|
|
9
9
|
Route,
|
|
10
|
+
RouterContext,
|
|
10
11
|
RouterState,
|
|
11
12
|
ToIdOption,
|
|
12
13
|
} from '@tanstack/router-core'
|
|
@@ -146,6 +147,10 @@ declare module '@tanstack/router-core' {
|
|
|
146
147
|
Component: RouteComponent
|
|
147
148
|
}
|
|
148
149
|
|
|
150
|
+
interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
|
|
151
|
+
useContext?: () => RouterContext
|
|
152
|
+
}
|
|
153
|
+
|
|
149
154
|
interface Router<
|
|
150
155
|
TRouteConfig extends AnyRouteConfig = RouteConfig,
|
|
151
156
|
TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>,
|
|
@@ -488,9 +493,15 @@ export function RouterProvider<
|
|
|
488
493
|
>({ children, router, ...rest }: RouterProps<TRouteConfig, TAllRouteInfo>) {
|
|
489
494
|
router.update(rest)
|
|
490
495
|
|
|
496
|
+
const defaultRouterContext = React.useRef({})
|
|
497
|
+
|
|
498
|
+
const userContext =
|
|
499
|
+
router.options.useContext?.() ?? defaultRouterContext.current
|
|
500
|
+
|
|
501
|
+
router.context = userContext
|
|
502
|
+
|
|
491
503
|
useRouterSubscription(router)
|
|
492
504
|
React.useEffect(() => {
|
|
493
|
-
console.log('hello')
|
|
494
505
|
return router.mount()
|
|
495
506
|
}, [router])
|
|
496
507
|
|
|
@@ -557,6 +568,12 @@ export function useRoute<
|
|
|
557
568
|
return router.useRoute(routeId as any) as any
|
|
558
569
|
}
|
|
559
570
|
|
|
571
|
+
export function useSearch<
|
|
572
|
+
TId extends keyof RegisteredAllRouteInfo['routeInfoById'] = keyof RegisteredAllRouteInfo['routeInfoById'],
|
|
573
|
+
>(_routeId?: TId): RegisteredAllRouteInfo['fullSearchSchema'] {
|
|
574
|
+
return useRouter().state.location.search
|
|
575
|
+
}
|
|
576
|
+
|
|
560
577
|
export function linkProps<TTo extends string = '.'>(
|
|
561
578
|
props: MakeLinkPropsOptions<RegisteredAllRouteInfo, '/', TTo>,
|
|
562
579
|
): React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
@@ -606,8 +623,6 @@ export function Outlet() {
|
|
|
606
623
|
Outlet,
|
|
607
624
|
)
|
|
608
625
|
}
|
|
609
|
-
|
|
610
|
-
console.log(match.matchId, 'suspend')
|
|
611
626
|
throw match.__.loadPromise
|
|
612
627
|
})() as JSX.Element
|
|
613
628
|
}
|