Skip to content

Commit 5ef34c6

Browse files
skellybrauchg
authored andcommitted
update styletron example to support multiple stylesheets (#763)
1 parent 23cddda commit 5ef34c6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

examples/with-styletron/pages/_document.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@ export default class MyDocument extends Document {
55
static getInitialProps ({ renderPage }) {
66
const page = renderPage()
77
const styletron = flush()
8-
const css = styletron ? styletron.getCss() : null
9-
return { ...page, css }
8+
const stylesheets = styletron ? styletron.getStylesheets() : []
9+
return { ...page, stylesheets }
1010
}
1111

1212
render () {
1313
return (
1414
<html>
1515
<Head>
1616
<title>My page</title>
17-
<style className='_styletron_hydrate_' dangerouslySetInnerHTML={{ __html: this.props.css }} />
17+
{this.props.stylesheets.map((sheet, i) => (
18+
<style
19+
className="_styletron_hydrate_"
20+
dangerouslySetInnerHTML={{ __html: sheet.css }}
21+
media={sheet.media || ''}
22+
key={i}
23+
/>
24+
))}
1825
</Head>
1926
<body>
2027
<Main />

0 commit comments

Comments
 (0)