From 02e44d13a97ff1295cca6603f33c17a1a24f939a Mon Sep 17 00:00:00 2001 From: Henri Date: Sun, 20 Jan 2019 14:41:49 +0100 Subject: [PATCH] [examples/react-jss] Add support for styled custom App component (#6094) With the current example it's not possible to use any components with styles inside a custom App component. Reference issue: cssinjs/jss#939 --- examples/with-react-jss/pages/_document.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/examples/with-react-jss/pages/_document.js b/examples/with-react-jss/pages/_document.js index f71f911aab..a18a4e9a27 100644 --- a/examples/with-react-jss/pages/_document.js +++ b/examples/with-react-jss/pages/_document.js @@ -3,16 +3,22 @@ import Document, { Head, Main, NextScript } from 'next/document' import { SheetsRegistry, JssProvider } from 'react-jss' export default class JssDocument extends Document { - static getInitialProps (ctx) { + static async getInitialProps (ctx) { const registry = new SheetsRegistry() - const page = ctx.renderPage(App => props => ( - - - - )) + const originalRenderPage = ctx.renderPage + ctx.renderPage = () => + originalRenderPage({ + enhanceApp: App => props => ( + + + + ) + }) + + const initialProps = await Document.getInitialProps(ctx) return { - ...page, + ...initialProps, registry } } -- GitLab