Skip to content

Instantly share code, notes, and snippets.

@kireerik
Last active March 3, 2018 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kireerik/c30a2d9bb2af394872b1e5774bc3a9c9 to your computer and use it in GitHub Desktop.
Save kireerik/c30a2d9bb2af394872b1e5774bc3a9c9 to your computer and use it in GitHub Desktop.
Material-UI: Get started (Fast!) ⚡ React 16+
import {renderToString} from 'react-dom/server'
import {ServerStyleSheet} from 'styled-components'
import Application from './application/Main'
const sheet = new ServerStyleSheet()
, html = renderToString(sheet.collectStyles(<Application />))
, css = sheet.getStyleTags()
// server response to send:
`<!DOCTYPE HTML>
<html lang="en">
<head>` + css + `</head>
<body>
<div id="root">` + html + `</div>
</body>
</html>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment