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?

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct