Commit b8291abe authored by nkzawa's avatar nkzawa

improve the styled-component example

parent 31feced2
......@@ -2,14 +2,11 @@ import Document, { Head, Main, NextScript } from 'next/document'
import styleSheet from 'styled-components/lib/models/StyleSheet'
export default class MyDocument extends Document {
static async getInitialProps (ctx) {
const renderPage = () => {
return ctx.renderPage()
}
const props = await Document.getInitialProps({ ...ctx, renderPage })
static async getInitialProps ({ renderPage }) {
styleSheet.flush()
const page = renderPage()
const style = styleSheet.rules().map(rule => rule.cssText).join('\n')
return { ...props, style }
return { ...page, style }
}
render () {
......
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