1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

update styletron example to support multiple stylesheets (#763)

This commit is contained in:
Shawn Kelly 2017-01-13 17:49:35 -06:00 committed by Guillermo Rauch
parent 23cddda9cf
commit 5ef34c6dd8

View file

@ -5,8 +5,8 @@ export default class MyDocument extends Document {
static getInitialProps ({ renderPage }) {
const page = renderPage()
const styletron = flush()
const css = styletron ? styletron.getCss() : null
return { ...page, css }
const stylesheets = styletron ? styletron.getStylesheets() : []
return { ...page, stylesheets }
}
render () {
@ -14,7 +14,14 @@ export default class MyDocument extends Document {
<html>
<Head>
<title>My page</title>
<style className='_styletron_hydrate_' dangerouslySetInnerHTML={{ __html: this.props.css }} />
{this.props.stylesheets.map((sheet, i) => (
<style
className="_styletron_hydrate_"
dangerouslySetInnerHTML={{ __html: sheet.css }}
media={sheet.media || ''}
key={i}
/>
))}
</Head>
<body>
<Main />