feat: add error message for async components (#413)

This commit is contained in:
Gustavo Henrique
2022-07-06 12:45:55 +02:00
committed by GitHub
parent a7b198fdf4
commit 10094f8947
+10
View File
@@ -400,6 +400,16 @@ export class ServerContext {
if (route.component === undefined) {
throw new Error("This page does not have a component to render.");
}
if (
typeof route.component === "function" &&
route.component.constructor.name === "AsyncFunction"
) {
throw new Error(
"Async components are not supported. Fetch data inside of a route handler, as described in the docs: https://fresh.deno.dev/docs/getting-started/fetching-data",
);
}
const preloads: string[] = [];
const resp = await internalRender({
route,