diff options
author | 2021-11-02 23:10:40 -0700 | |
---|---|---|
committer | 2021-11-02 23:10:40 -0700 | |
commit | 92e5fe9fd5b31d8b0ac8327a221b20dd03218502 (patch) | |
tree | ec29767d18dd3e0c540ab612ab2cf2c258e04a9e /packages/bun-framework-next/renderDocument.tsx | |
parent | b107ac16599b67cd050977531914b774adcceead (diff) | |
download | bun-92e5fe9fd5b31d8b0ac8327a221b20dd03218502.tar.gz bun-92e5fe9fd5b31d8b0ac8327a221b20dd03218502.tar.zst bun-92e5fe9fd5b31d8b0ac8327a221b20dd03218502.zip |
Next.js 12 support
Diffstat (limited to 'packages/bun-framework-next/renderDocument.tsx')
-rw-r--r-- | packages/bun-framework-next/renderDocument.tsx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/bun-framework-next/renderDocument.tsx b/packages/bun-framework-next/renderDocument.tsx index 463395863..615224f0d 100644 --- a/packages/bun-framework-next/renderDocument.tsx +++ b/packages/bun-framework-next/renderDocument.tsx @@ -243,6 +243,7 @@ function renderDocument( scriptLoader, locale, disableOptimizedLoading, + useMaybeDeferContent, ...docProps, }; return ( @@ -567,6 +568,17 @@ export async function render({ </AppContainer> ); }, + defaultGetInitialProps: async ( + docCtx: DocumentContext + ): Promise<DocumentInitialProps> => { + const enhanceApp = (AppComp: any) => { + return (props: any) => <AppComp {...props} />; + }; + + const { html, head } = await docCtx.renderPage({ enhanceApp }); + // const styles = jsxStyleRegistry.styles(); + return { html, head }; + }, }; var props = await loadGetInitialProps(AppComponent, { @@ -789,6 +801,7 @@ export async function render({ isPreview: isPreview === true ? true : undefined, autoExport: isAutoExport === true ? true : undefined, nextExport: nextExport === true ? true : undefined, + useMaybeDeferContent, }); const bodyRenderIdx = html.indexOf(BODY_RENDER_TARGET); html = @@ -812,3 +825,10 @@ export async function render({ ); } } + +export function useMaybeDeferContent( + _name: string, + contentFn: () => JSX.Element +): [boolean, JSX.Element] { + return [false, contentFn()]; +} |