Unverified Commit 1773b991 authored by Michael McQuade's avatar Michael McQuade Committed by GitHub

[examples] Wrap entire app with Styletron provider for with-styletron (#21908)

parent 958bd6ca
......@@ -8,10 +8,10 @@
},
"dependencies": {
"next": "latest",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"styletron-engine-atomic": "^1.1.2",
"styletron-react": "^5.0.1"
"react": "17.0.1",
"react-dom": "17.0.1",
"styletron-engine-atomic": "1.4.6",
"styletron-react": "5.2.7"
},
"license": "MIT"
}
......@@ -3,14 +3,22 @@ import { Provider as StyletronProvider } from 'styletron-react'
import { styletron } from '../styletron'
class MyDocument extends Document {
static getInitialProps(props) {
const page = props.renderPage((App) => (props) => (
<StyletronProvider value={styletron}>
<App {...props} />
</StyletronProvider>
))
static async getInitialProps(context) {
const renderPage = () =>
context.renderPage({
enhanceApp: (App) => (props) => (
<StyletronProvider value={styletron}>
<App {...props} />
</StyletronProvider>
),
})
const initialProps = await Document.getInitialProps({
...context,
renderPage,
})
const stylesheets = styletron.getStylesheets() || []
return { ...page, stylesheets }
return { ...initialProps, stylesheets }
}
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