diff --git a/pages/_document.js b/pages/_document.js index df661e8..f53de5a 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -3,15 +3,20 @@ 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 ( - {styleTags} + {this.props.styleTags} -
{main}
+
+
+