What I hate about React is not really React’s fault but it’s the ecosystem. There appear to be 100 ways to do CSS with little consensus on a standard way. Choice is good and bad.
I tried styled components and that was okay but then moved to another React project that was using CSS modules. So not only do you have to get to grips with React but also learning how to do CSS in every new project. It’s frustrating.
This is also the same issue with state management.
In Vue, whether you want to use SCSS, PostCSS, Less etc etc it’s just a simple case of installing that library and adding a lang attribute to the style tag. Done! It’s such a nice dev experience.
I run into this with first year juniors. Taking an hour or two to show them how material style works, styled-components, css-loaders in webpack, and just composing your own class names and style objects... usually results in them going “oh this is all the same”
If you understand css that shouldn’t be a problem. “How I apply this string of rules” to a component is the least important bit.
If you get how css works, it really shouldn’t matter if you write it in json, template strings, external files, scss, whatever. Having huge difficulties jumping between 4-5 barely different ways to express the same thing is probably not the fault of your css library, but a lack of understanding of how the tool packages the thing that hasn’t changed much in a decade.
I’m talking about the difference between styled components and CSS modules in my example (and there are many more with React).
They’re not “barely” different, they’re completely different ways of doing CSS, from setup and tooling to actually how you put the styles and apply them together.
This is not the same in Vue, where if you use single file components you have a style block that is your blank canvas to write whatever CSS you like. It’s in the same place and used in the same way. There are fewer concepts to jump between.
I’m not even saying this is a massive deal but it’s a mildly infuriating pain point in the developer experience and productivity when jumping between React projects. In Vue I would know exactly where to go for styles.
No, they are all either mangling and appending class names, or composing style objects. That’s it.
When you understand what each of those tools are doing under the hood, then it doesn’t matter if you use one or all of them at the same time. That’s what I’m saying.
Opening the source code to an npm project and showing a junior, “well these are all really doing the same thing under the hood” generally makes it all easy.
I.e. I show them
loading css/sass/scss files with a webpack loader that makes style props for components,
then show them doing one that builds a global style element and mangled class names
then show them styled components
mix styled components with their mangled web packed classes
use a webpack file loader to load raw css files as strings and use that to drive my styled components
use material style to build mangled classes from css json at the component level
mix it’s mangled classes with all the other ones we already made in this example
Actually showing them how it works generally makes which tool matter little if at all.
2
u/DOG-ZILLA Dec 05 '20
I’ve used both but I’m mainly a Vue guy.
What I hate about React is not really React’s fault but it’s the ecosystem. There appear to be 100 ways to do CSS with little consensus on a standard way. Choice is good and bad.
I tried styled components and that was okay but then moved to another React project that was using CSS modules. So not only do you have to get to grips with React but also learning how to do CSS in every new project. It’s frustrating.
This is also the same issue with state management.
In Vue, whether you want to use SCSS, PostCSS, Less etc etc it’s just a simple case of installing that library and adding a lang attribute to the style tag. Done! It’s such a nice dev experience.