Skip to content

Commit

Permalink
update styletron example to support multiple stylesheets (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
skellyb authored and rauchg committed Jan 13, 2017
1 parent 23cddda commit 5ef34c6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions examples/with-styletron/pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ 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 () {
return (
<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 />
Expand Down

0 comments on commit 5ef34c6

Please sign in to comment.