News for hackers. Stuff that matters.
Re:Why I Write CSS in JavaScript by akuji1993 on Monday February 18, 2019 @09:59AM (#19191034)
Hm, I don't share your opinion on this matter, to be honest. You can easily avoid this in both Angular (which does it out of the box) and React by including CSS Modules (https://github.com/css-modules/css-modules) which, if you use create-react-app to build your projects, is a 5 minute change to your architecture. So there really is no reason to write that down as a con for React.
Re:Why I Write CSS in JavaScript by preommr on Monday February 18, 2019 @10:57AM (#19191562)
I have so many small components that I would loathe to have a separate stylesheet. Yes, it's a small thing to just switch tabs, but this is a small problem. And these small problems add up and can be a huge pain. I really really like the SFCs in vue and compare it to a bit of butter on toast. It might be a small thing, but it seems like it makes a big difference.
Re:Why I Write CSS in JavaScript by antihero on Monday February 18, 2019 @11:43AM (#19191934)
So you can just use styled-components as in the OP
Re:Why I Write CSS in JavaScript by therealmarv on Monday February 18, 2019 @02:07PM (#19193290)
You can avoid many things by forcing yourself to use this and this practice. In my experience not all developers out there know what is "good" and what is "bad" practice and there are certainly many React developers out there who never heard about CSS modules. Let's say better it's not a flaw in React but a trap which can cause huge maintenance headache in my opinion.
Re:Why I Write CSS in JavaScript by scottrepreneur on Monday February 18, 2019 @10:07AM (#19191114)
Works out of the box for the most recent version of CRA, as well.
Re:Why I Write CSS in JavaScript by dictum on Monday February 18, 2019 @10:12AM (#19191170)
You're right, but community support around a certain pattern often makes it the de-facto practice, so defaults matter even for a non-opinionated library (where "defaults" are essentially what tutorials and thought leaders point to)
Re:Why I Write CSS in JavaScript by cynicalreason on Monday February 18, 2019 @10:56AM (#19191555)
I always thought css-modules is the de-facto practice
Re:Why I Write CSS in JavaScript by therealmarv on Monday February 18, 2019 @01:59PM (#19193213)
I know a ton of companies who did not even heard the memo about it.