Skip to content

Commit

Permalink
Update insertCss example to match react-starter-kit (#61)
Browse files Browse the repository at this point in the history
* Update insertCss example to match react-start-kit

See https://github.com/kriasoft/react-starter-kit/blob/a32e7b6dd72386986ab5117b562485dd8771176d/src/server.js#L101

* Replace css array with Set

* Fix mistakes in Array to Set changes
  • Loading branch information
jasonsanjose authored and koistya committed Sep 30, 2016
1 parent fb0db41 commit 1e70aff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -91,15 +91,15 @@ const port = process.env.PORT || 3000;

// Server-side rendering of the React app
server.get('*', (req, res, next) =>
const css = []; // CSS for all rendered React components
const context = { insertCss: (styles) => css.push(styles._getCss()) };
const css = new Set(); // CSS for all rendered React components
const context = { insertCss: (...styles) => styles.forEach(style => css.add(style._getCss())); };
router.dispatch({ ...req, context }).then((component, state) => {
const body = ReactDOM.renderToString(component);
const html = `<!doctype html>
<html>
<head>
<script async src="/client.js"></script>
<style type="text/css">${css.join('')}</style>
<style type="text/css">${[...css].join('')}</style>
</head>
<body>
<div id="root">${body}</div>
Expand Down

0 comments on commit 1e70aff

Please sign in to comment.