From 093b091a5c00bc73691be79619f9a09ee981b65c Mon Sep 17 00:00:00 2001 From: Shaleen Jain Date: Thu, 14 Sep 2017 17:47:18 +0530 Subject: [PATCH] Update styled components example (#2945) * Update styled components example Updates the styled-components example to pass HOC to renderPage() and fix SSR. * fix lint errors --- examples/with-styled-components/pages/_document.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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} -
+