4 ms·
> For example, say your app has a dark mode. All your rendered components must know what theme is on, so they can render the UI in the right color. Wait, what?
by kerkeslager 7y ago
> For example, say your app has a dark mode. All your rendered components must know what theme is on, so they can render the UI in the right color.
Wait, what? Hell no. This is literally the core use case for CSS classes. And while there are cases where CSS classes can cause problems, this isn't one of them. This is a case where CSS classes shine.
This is like an article on how to use fire to solve problems, and instead of choosing an example like staying warm or cooking food, the author leads with an example like disposing of tires by burning them in the rainforest. It's just an unambiguously bad idea.
There were a bunch of places where I wasn't familiar with the tools he's using and am curious, but I'm certainly suspicious of anything he suggests after the "use global state to reinvent CSS classes via JS" suggestion.
- austincheney 7y agoYeah, I have a stylesheet for layout and then one for each color scheme. Changing the scheme is literally changing the class attribute of the body tag. Maintaining state isn’t that much harder.