File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,16 @@ const globalX = globalThis as unknown as {
13
13
const match = getRouteMatcher ( globalX . __ROUTES__ ) ;
14
14
15
15
export async function hydrate (
16
- Shell : React . ComponentType < { children : React . ReactElement } & ServerSideProps >
16
+ Shell : React . ComponentType <
17
+ { children : React . ReactElement } & ServerSideProps
18
+ > ,
19
+ options ?: Omit < React . PropsWithoutRef < typeof RouterHost > , "children" | "Shell" >
17
20
) {
18
21
const matched = match ( globalX . __INITIAL_ROUTE__ . split ( "?" ) [ 0 ] ) ! ;
19
22
const Initial = await import ( matched . value ) ;
20
23
return hydrateRoot (
21
24
document ,
22
- < RouterHost Shell = { Shell } >
25
+ < RouterHost Shell = { Shell } { ... options } >
23
26
< Shell { ...globalX . __SERVERSIDE_PROPS__ } >
24
27
< Initial . default { ...globalX . __SERVERSIDE_PROPS__ ?. props } />
25
28
</ Shell >
Original file line number Diff line number Diff line change @@ -42,9 +42,11 @@ export const ReloadContext = createContext(async (): Promise<void> => {});
42
42
export const RouterHost = ( {
43
43
children,
44
44
Shell,
45
+ onRouteUpdated,
45
46
} : {
46
47
children : React . ReactElement ;
47
48
Shell : React . ComponentType < { children : React . ReactElement } > ;
49
+ onRouteUpdated ?: ( path : string ) => void ;
48
50
} ) => {
49
51
const pathname = useLocationProperty (
50
52
( ) => location . pathname + location . search ,
@@ -64,6 +66,7 @@ export const RouterHost = ({
64
66
if ( props ?. redirect ) {
65
67
navigate ( props . redirect ) ;
66
68
} else {
69
+ onRouteUpdated ?.( target ) ;
67
70
setCurrent (
68
71
< Shell { ...props } >
69
72
< module . default { ...props ?. props } />
@@ -81,6 +84,7 @@ export const RouterHost = ({
81
84
location . href = pathname ;
82
85
} ) ;
83
86
} else {
87
+ onRouteUpdated ?.( pathname ) ;
84
88
// @ts -ignore
85
89
delete globalX . __INITIAL_ROUTE__ ;
86
90
}
You can’t perform that action at this time.
0 commit comments