4 ms·
Strongly agree. I just don’t get the hate for JSX. JSX is objectively better than than the scores of templating systems out there. You get much more: type chec
by prmph 4y ago
Strongly agree. I just don’t get the hate for JSX.
JSX is objectively better than than the scores of templating systems out there. You get much more: type checking, use of JS for logic, and no need to learn yet custom arcane syntax. If anything, I think JSX is not used and supported enough.
In the general sense, JSX is just syntactic sugar for function composition. That it works well for html-style components is a side effect; it could certainly be used for more than that.
I wish languages like Typescript would support JSX natively, with absolutely to dependency on any React-like library. Let me declare a function using JSX, e.g.,
type Mode = “upper” | “lower”
const capitalize = (str: string, mode: Mode) => mode === “upper”? str.toUpperCase() : str.toLowerCase()
const join = (mode: Mode, …arr: string[]) => arr.map(str => <capitalize {{ str, mode }}/>).join()
const joined = <join mode=“lower”>Bon Jovi /> // “bonjovi”