Skip to content
Hill Liu edited this page Feb 27, 2016 · 13 revisions

Explain how to render CSS style in server side.

  1. In server side you could render css style directly.

  2. And for react-dom you could use renderToString and use a special flag to split normal output and react-dom.

    • Such as

var tmp = ReactServer.renderToString(MyApp( myJson )); console.log(''+tmp);

* Code: https://github.com/pmvc-theme/hello_react/blob/master/server.js

3. So for finial rendering, you could split two type content (html & css style), then react will not complain client and server have different output anymore.
* Code example: https://github.com/pmvc-plugin/view_react/blob/master/view_react.php#L38-L46