diff --git a/examples/with-styled-components/pages/_document.js b/examples/with-styled-components/pages/_document.js index 77104a49..25faf5d4 100644 --- a/examples/with-styled-components/pages/_document.js +++ b/examples/with-styled-components/pages/_document.js @@ -2,20 +2,22 @@ import Document, { Head, Main, NextScript } from 'next/document' import { ServerStyleSheet } from 'styled-components' export default class MyDocument extends Document { - render () { + static getInitialProps ({ renderPage }) { const sheet = new ServerStyleSheet() - const main = sheet.collectStyles(
) + const page = renderPage(App => props => sheet.collectStyles()) const styleTags = sheet.getStyleElement() + return { ...page, styleTags } + } + + render () { return ( My page - {styleTags} + {this.props.styleTags} -
- {main} -
+