News for hackers. Stuff that matters.
Re:React is a fractal of bad design by prmph on Wednesday March 08, 2023 @10:03AM (#35069814)
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 is languages would support JSX natively, with absolutely to ties to React. 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”

There are no comments on this comment yet.