News for hackers. Stuff that matters.
Re:Web Components Eliminate JavaScript Framework Lock-In by nostrademons on Monday November 27, 2023 @01:07PM (#38435789)
I liked the templates-as-JSON approach much more than JSX. HTML is terribly verbose, doesn't fit well with the rest of Javascript, doesn't let you use JS language features like destructuring or iteration on the component tree, and doesn't let you factor out common properties into their own data structure. Would much rather see:

    { tag: 'div', padding: '2px', position: 'absolute', content: [myText] }
than

    <div style="padding: 2px; position: 'absolute'">${myText}</div>
The main reason I ended up settling for JSX was just convention: I don't want to be the one with my own unique format for UI trees unless I can convince everybody else to use my format.

Note that Jetpack Compose has a very similar declarative reactive paradigm as React, but represents components with Kotlin language mechanisms. IMHO I like it much better, because it's much more composeable.

There are no comments on this comment yet.