3 ms·
> just need to persuade myself to accept it mixed in JS file Why is this a bad thing? The most important thing about JSX is that it's a single source of truth
by ng12 9y ago
> just need to persuade myself to accept it mixed in JS file
Why is this a bad thing? The most important thing about JSX is that it's a single source of truth -- you never have to wonder if data is processed in the JS or in the template. I really think everything in one file is the ideal, we've even started moving the styles inline via styled-components.
- miroslavpopovic 9y agoNot a bad thing. Just a personal preference of trying to separate views and view models for a long time. I believe it just needs some time to get used to it. As I said, I really do like declarative nature of JSX, knowing that it's just compiled to a regular JS/DOM code.
- foota 9y agoFwiw I think "compiled to" is a bit of a misnomer. From my understanding it's more like a DSL that gets interpreted by the renderer.
- ng12 9y agoI think compilation is fair wording -- JSX is just sugar around the createElement API. : https://facebook.github.io/react/docs/react-api.html#createelement https://facebook.github.io/react/docs/react-api.html#createe...
- foota 9y agoA bit late, but my thought is that compiled to js/Dom api to me implies that it's compiled directly to document.createElement and friends.