Sign in
Log inSign up

How do you deal with styles in React?

Sergei's photo
Sergei
·Apr 22, 2016

I would like to know how do you guys deal with styles in React components especially when it comes to server side rendering.

I am using Webpack and making bundles for client and server. At this moment I figured out that there are several options:

  • use ExtractTextPlugin to extract all styles to a single file and hang it up to HTML while rendering on server;
  • use simple inline styles. In this case we can't use pre/post processors;
  • require styles conditionally like if (BROWSER) require('./style.css'). In this case server rendered components do not have styles at all and they'll be applied after the client app starts;
  • maybe to use of some modules/plugins.

How do you deal with it?