fix: missing Component with async app + layout (#1848)

This commit is contained in:
Marvin Hagemeister
2023-10-04 14:10:11 +02:00
committed by GitHub
parent bed185688c
commit f7000c3f53
8 changed files with 80 additions and 1 deletions
+9 -1
View File
@@ -226,7 +226,15 @@ export async function render<Data>(
componentFn.displayName = (fn as any).displayName || fn.name;
componentStack[i] = componentFn;
} else {
componentStack[i] = fn;
componentStack[i] = () => {
return h(fn, {
...props,
Component() {
return h(componentStack[i + 1], null);
},
// deno-lint-ignore no-explicit-any
} as any);
};
}
}
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/
import dev from "$fresh/dev.ts";
await dev(import.meta.url, "./main.ts");
+19
View File
@@ -0,0 +1,19 @@
// DO NOT EDIT. This file is generated by Fresh.
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.
import * as $0 from "./routes/_app.tsx";
import * as $1 from "./routes/_layout.tsx";
import * as $2 from "./routes/index.tsx";
const manifest = {
routes: {
"./routes/_app.tsx": $0,
"./routes/_layout.tsx": $1,
"./routes/index.tsx": $2,
},
islands: {},
baseUrl: import.meta.url,
};
export default manifest;
+10
View File
@@ -0,0 +1,10 @@
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
await start(manifest);
+9
View File
@@ -0,0 +1,9 @@
import { defineApp } from "$fresh/server.ts";
export default defineApp((req, { Component }) => {
return (
<div class="app">
<Component />
</div>
);
});
@@ -0,0 +1,11 @@
import { LayoutProps } from "$fresh/server.ts";
export default function RootLayout(
{ Component }: LayoutProps<unknown>,
) {
return (
<div class="root-layout">
<Component />
</div>
);
}
+7
View File
@@ -0,0 +1,7 @@
export default function Home() {
return (
<div class="home-page">
Home
</div>
);
}
+10
View File
@@ -191,3 +191,13 @@ Deno.test({
);
},
});
Deno.test("mix async app and layouts", async () => {
await withFakeServe(
"./tests/fixture_layouts_2/main.ts",
async (server) => {
const doc = await server.getHtml(`/`);
assertSelector(doc, ".app > .root-layout > .home-page");
},
);
});