fix: missing Component with async app + layout (#1848)
This commit is contained in:
@@ -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);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export default function Home() {
|
||||
return (
|
||||
<div class="home-page">
|
||||
Home
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -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");
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user