export async function render(uri: string, req: RenderRequest): Promise<{ html: RenderStream, head?: RenderStream }> {
const [lang,] = await loadTranslationsForLanguage(req.common!.requestLanguage)
const common = req.common!
const ctx = new AppCtx(common.selfContext?.user ?? null, common, lang)
const comp = <App ctx={ctx} uri={uri} pageCommon={req.common!} pagePayload={req.payload!.value!} />
// ^ This was problematic because it wasn't inside the function in renderToStream.
// Nevertheless, there was no warning and the runtime error was confusing and did not allude to the core issue.
const html = renderToStream(() => comp)
return { html }
}
export async function render(uri: string, req: RenderRequest): Promise<{ html: RenderStream, head?: RenderStream }> {
const [lang,] = await loadTranslationsForLanguage(req.common!.requestLanguage)
const common = req.common!
const ctx = new AppCtx(common.selfContext?.user ?? null, common, lang)
const comp = <App ctx={ctx} uri={uri} pageCommon={req.common!} pagePayload={req.payload!.value!} />
// ^ This was problematic because it wasn't inside the function in renderToStream.
// Nevertheless, there was no warning and the runtime error was confusing and did not allude to the core issue.
const html = renderToStream(() => comp)
return { html }
}