4 ms·
> I never understood the fascination with JSX. HTML templating (without JSX) gives you markup as strings, which means you don't get type checks, auto-complete,
by jeswin 2y ago
> I never understood the fascination with JSX.
HTML templating (without JSX) gives you markup as strings, which means you don't get type checks, auto-complete, syntax highlighting etc.
- mock-possum 2y agoHave you checked out lithtml?
- jeswin 2y agoYeah. It requires a framework specific plugin in vscode (and other IDEs), since the markup is just text which requires framework-specific interpretation. Ultimately, like everything else it's trade-offs and personal preference.
- esperent 2y agoDo you mean lit html? I've seen it before, it uses template strings for html templating: const myTemplate = (name) => html`<div>Hello ${name}</div>`; Compared to JSX, I don't like it much. I feel that template strings are unergonomic and fiddly to type a lot, although maybe I'd get used to it.
- nchmy 2y agoIt's literally just plain html and JavaScript...
- gryzzly 2y agoit’s really a funny point, as if JSX is somehow native? JSX requires a compiler and definitely also editor extensions for syntax and auto-complete and type checks.
- WorldMaker 2y agoSure, but the most common JSX compiler and language service is Typescript and Typescript is well supported everywhere. As the de facto language service for most JS work today, it certainly feels more like "native" than other template compilers. Also, for what it is worth, JSX is mostly (despite a few attempts from React to complicate it) a very simple syntax transformer to boring function calls for mostly easy to write functions. We've had "h" functions for a long time before JSX and we'll have "h" functions still if JSX stops being an interesting thing to support.
- gryzzly 2y agowell supported? the point is that you have to install additional tools for either syntax.
- WorldMaker 2y agoWell supported as in Typescript is the tool that you already have installed in neovim or in VS Code or in JetBrains editors or in almost anything else that supports modern Language Server Protocol to do JS language services. Typescript is the LSP a lot of people use daily for all JS work (whether or not they also use types/Typescript). There's no additional install for JSX syntax highlighting or auto-completion because it's also built into the Typescript LSP.
- nchmy 2y agoUse template literals and an extension, like those for lit-html - full syntax highlighting. No compiling necessary.