Skip to content

Commit

Permalink
add route parameter to shell
Browse files Browse the repository at this point in the history
  • Loading branch information
codehz committed Dec 29, 2023
1 parent bbcb205 commit 254076c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion hydrate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export async function hydrate(
return hydrateRoot(
document,
<RouterHost Shell={Shell} {...options}>
<Shell {...globalX.__SERVERSIDE_PROPS__}>
<Shell
route={globalX.__INITIAL_ROUTE__}
{...globalX.__SERVERSIDE_PROPS__}
>
<Initial.default {...globalX.__SERVERSIDE_PROPS__?.props} />
</Shell>
</RouterHost>,
Expand Down
2 changes: 1 addition & 1 deletion index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class StaticRouters {
});
}
const stream = await renderToReadableStream(
<Shell {...result}>
<Shell route={serverSide.pathname + search} {...result}>
<module.default {...result?.props} />
</Shell>,
{
Expand Down
4 changes: 2 additions & 2 deletions router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const RouterHost = ({
onRouteUpdated,
}: {
children: React.ReactElement;
Shell: React.ComponentType<{ children: React.ReactElement }>;
Shell: React.ComponentType<{ children: React.ReactElement; route?: string }>;
onRouteUpdated?: (path: string) => void;
}) => {
const pathname = useLocationProperty(
Expand All @@ -95,7 +95,7 @@ export const RouterHost = ({
onRouteUpdated?.(target);
setVersion(currentVersion);
setCurrent(
<Shell {...props}>
<Shell route={target} {...props}>
<module.default {...props?.props} />
</Shell>
);
Expand Down

0 comments on commit 254076c

Please sign in to comment.