3 ms·
> It makes it absurdly difficult to share common styles across components. It's a feature, not bug. In the world where many components are created independentl
by fiedzia 4y ago
> It makes it absurdly difficult to share common styles across components.
It's a feature, not bug. In the world where many components are created independently by different developers, It's suddenly possible to define element style easily, without requiring you to consider affecting tons of other things that are not in any way related and you know nothing about. Less sharing is good when sharing requires expensive coordination.
- reverius42 4y agoWish I could give this more than one upvote. Having worked on large (30+) teams sharing a single CSS/JS/HTML codebase, styled components is the only sane solution -- CSS seems like a simpler way to share styles when you have a few components, but when you have a few thousand it's way more important to isolate changes from each other. CSS in JS still allows for sharing of styles between components, but which styles and how they are shared must be explicitly wired up in JS instead of "cascading" (i.e. magically applying in lots of places). Again, this is a good thing.
- SebastianKra 4y agoI like css-in-js, but it's not the only way of creating isolated styles. CSS-Modules solves it by generating hashed classnames from css-files. Tailwind has global classes, but the styling of each element is local.
- shubhamjain 4y agoEven if the components are different, more often than not they will share same fundamental styles (margins, paddings, radius, colors) because of design systems. What's the point of repeating all the standardized things again and again? Normally, you don't even need a component for something like a Heading, or Paragraph. With 'styled-components' you need to create extremely trivial components, that just need some styling. Conflicts aren't really a problem if your conventions are sane.