Skip to content

Instantly share code, notes, and snippets.

@SaraVieira
Created February 14, 2018 00:07
Show Gist options
  • Save SaraVieira/b7468b94bb54e5ee1824b3a0a1bcc0f8 to your computer and use it in GitHub Desktop.
Save SaraVieira/b7468b94bb54e5ee1824b3a0a1bcc0f8 to your computer and use it in GitHub Desktop.
import App from './components/app';
import { h, render } from 'preact';
import { default as renderToString } from 'preact-render-to-string';
import { ServerStyleSheet } from 'styled-components'
if(typeof window === undefined) {
const sheet = new ServerStyleSheet()
const html = renderToString(sheet.collectStyles(<App />))
const styleTags = sheet.getStyleTags() // or sheet.getStyleElement()
}
if (typeof window !== "undefined") {
render((
<App />
), document.getElementById('root'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment