Skip to content

[React Style] Server side

Hill Liu edited this page Mar 9, 2022 · 7 revisions

Explain how to render CSS style in server side.

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

  2. You could use a special flag to separate normal output (console.log) and react output (ReactServer.renderToString).

    • Such as
var tmp = ReactServer.renderToString(MyApp(
    myJson 
));
console.log('<!--start-->'+tmp);
  1. So far, you could have two types of content (html & css style), then react will not complain client and server have different output anymore.