Unverified Commit fcc4d8cd authored by agstover's avatar agstover Committed by GitHub

await ctx.renderPage() in examples for TypeScript (#15528)

Co-authored-by: 's avatarJoe Haddad <joe.haddad@zeit.co>
parent 1968f7f5
......@@ -3,7 +3,7 @@ import cxs from 'cxs/lite'
export default class MyDocument extends Document {
static async getInitialProps({ renderPage }) {
const page = renderPage()
const page = await renderPage()
const style = cxs.getCss()
return { ...page, style }
}
......
......@@ -3,7 +3,7 @@ import { renderStatic } from 'glamor/server'
class MyDocument extends Document {
static async getInitialProps({ renderPage }) {
const page = renderPage()
const page = await renderPage()
const { css, ids } = renderStatic(() => page.html || page.errorHtml)
return { ...page, css, ids }
}
......
......@@ -2,9 +2,8 @@ import Document, { Head, Main, NextScript } from 'next/document'
import { extractCss } from 'goober'
export default class MyDocument extends Document {
static getInitialProps({ renderPage }) {
const page = renderPage()
static async getInitialProps({ renderPage }) {
const page = await renderPage()
// Extrach the css for each page render
const css = extractCss()
return { ...page, css }
......
......@@ -15,7 +15,7 @@ export default class MyDocument extends Document {
static async getInitialProps({ renderPage }) {
AppRegistry.registerComponent(config.name, () => Main)
const { getStyleElement } = AppRegistry.getApplication(config.name)
const page = renderPage()
const page = await renderPage()
const styles = [
<style dangerouslySetInnerHTML={{ __html: normalizeNextElements }} />,
getStyleElement(),
......
......@@ -10,7 +10,7 @@ import { extractCritical } from '@emotion/server'
export default class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
const page = ctx.renderPage()
const page = await ctx.renderPage()
const styles = extractCritical(page.html)
return { ...initialProps, ...page, ...styles }
}
......
......@@ -2,8 +2,8 @@ import Document, { Head, Main, NextScript } from 'next/document'
import { getStyles } from 'typestyle'
export default class MyDocument extends Document {
static getInitialProps({ renderPage }) {
const page = renderPage()
static async getInitialProps({ renderPage }) {
const page = await renderPage()
const styleTags = getStyles()
return { ...page, styleTags }
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment