> Sure CSS in JS if you want.
What do you think the code you complained about does?
> But scrapping CSS for style tags is a bad idea.
It's not bad in this particular case because these were simple examples to illustrate an entirely different point.
> React renders to the DOM which outputs HTML. It's still HTML
Erm. No. DOM never outputs any HTML. There's no HTML generated when you use React (or any other DOM-manipulation library or vanilla Javascript).
It's the other way around:
- HTML gets parsed
- A DOM (Document Object Model) is created to provide an in-memory, well, object model of the HTML document.
- In order to render anything on screen the browser works with the DOM only
- When something manipulates the DOM directly, the browser reacts to those changes and re-renders the view accordingly
- There's no HTML generated
- If someone does change the HTML, it's re-parsed, go to step 1.
Yes, you can style DOM nodes independently of React because that's how CSS works. However, there is a reason why people hate CSS with a passion: it doesn't scale, it's cumbersome to develop components with it etc. etc. etc. And that's why people ended up inventing ways to include/generate CSS via JS alongside component code.