3 ms·
We're migrating to styled-components at my current company. It's nice for abstracting components -- either into shared libraries or separate micro-clients that
by TimTheTinker 5y ago
We're migrating to styled-components at my current company. It's nice for abstracting components -- either into shared libraries or separate micro-clients that are composed together at runtime.
In those scenarios, there are a few benefits: (a) no worries about accidentally trampling on someone else's styles, or styles from elsewhere overriding your styles; (b) build configuration is simpler; and (c) no worries about how CSS/SCSS is referenced/loaded - all references are handled in plain JS with no special loaders or anything.
I wouldn't use it everywhere (I've used other approaches that have worked just fine), but for some scenarios it makes sense.
- 11235813213455 5y agolike you say, the benefit is to easily attach styles to components (in the same programming language, compared to scss/css modules) note: @emotion/styled is equivalent to styled-components, lighter and easier to set up for SSR (it works out of the box https://emotion.sh/docs/ssr#default-approach https://emotion.sh/docs/ssr#default-approach) When using server-side rendered pages, there's no performance loss on the client-side, maybe a little more processing server-side, not sure if significant
- alexchamberlain 5y agoDoesn't SCSS support CSS modules to prevent trampling on each others styles?