News for hackers. Stuff that matters.
Re:10 years of Front end Development. I quit by jamespetercook on Thursday May 21, 2020 @06:17PM (#23266148)
The whole CSS in JS thing is so backwards. I use React a lot and I love it, but styles stay in a css file structured using BEM. It works.
Re:10 years of Front end Development. I quit by tvphan on Thursday May 21, 2020 @06:28PM (#23266260)
I thought the same thing until you start to think in terms of “constraint-based components”, which are more easily done in CSS-in-JS. Styling is done by passing properties to a component, e.g. <Heading color=“primary” />, and only the developer building the primitive component needs to worry about styling. You end up being able to rapidly develop interfaces that match the designs.
Re:10 years of Front end Development. I quit by jamespetercook on Friday May 22, 2020 @04:50AM (#23269956)
If I understand correctly you can still do that, just the underlying component will be adding/removing a CSS class instead of injecting the actual styles. I usually use the classnames library to help with this but obviously not a requirement (https://www.npmjs.com/package/circular-dependency-plugin) I find it's also easier to test for the presence of css classnames based on the provided props than it is to test for the presence of mutiple style rules.