fix(server): make LayoutProps generic (#1592)
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import { LayoutProps } from "$fresh/server.ts";
|
||||
import { LayoutState } from "./_middleware.ts";
|
||||
|
||||
export default function RootLayout({ Component }: LayoutProps) {
|
||||
export default function RootLayout(
|
||||
{ Component, state }: LayoutProps<unknown, LayoutState>,
|
||||
) {
|
||||
return (
|
||||
<div class="root-layout">
|
||||
{state.something === "it works" ? "it works\n" : "it doesn't work\n"}
|
||||
<Component />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { MiddlewareHandlerContext } from "$fresh/server.ts";
|
||||
|
||||
export type LayoutState = {
|
||||
something: string;
|
||||
};
|
||||
|
||||
export const handler = (
|
||||
_req: Request,
|
||||
ctx: MiddlewareHandlerContext<LayoutState>,
|
||||
) => {
|
||||
ctx.state.something = "it works";
|
||||
return ctx.next();
|
||||
};
|
||||
Reference in New Issue
Block a user