It’s always been strange to me that static templating is such an obvious use case for JSX, but it’s hard to find good tooling that isn’t just wrapping React. When I’ve looked into it in the past, I came to the same conclusion as you that React.renderToStaticMarkup is good enough, but it still feels like bringing a bazooka to a knife fight.
The most robust-looking alternative I’ve found is vhtml (from the creator of Preact), but it doesn’t seem that actively maintained. Then again, if it’s doing one thing and doing it well, maybe it doesn’t need to be.
Yeah honestly if you want to “just” output the HTML, you can write a thing yourself. There’s not really much to do, and any lib will be feature complete extremely quickly. The “maintenance question” should not hold you back from using something like vhtml!
FWIW, I think JSX was more inspired by PHP than E4X. React was built by Facebook, for Facebook, which was sitting on a very large PHP/Hack codebase.
E4X was probably also inspired by PHP, but it was focused on using XML as a data format more than as a rendering target. I miss using it in ActionScript, TBH. In React it’s very easy to make nested components, but querying the tree is very difficult. E4X was all about querying the tree! And it was typesafe IIRC, at least in AS3 — the compiler could parse XML and make sure your queries actually would return what you wanted, assuming you were using static XML files for config.
Of course, today you can statically check your JSON configs with TypeScript, but sometimes JSON just isn’t the right config language — for example, writing dialogue trees in games in XML is easy, but you’re gonna want a wrapper tool or UI for it in JSON or you’ll go insane escaping characters by hand.
It’s always been strange to me that static templating is such an obvious use case for JSX, but it’s hard to find good tooling that isn’t just wrapping React. When I’ve looked into it in the past, I came to the same conclusion as you that
React.renderToStaticMarkupis good enough, but it still feels like bringing a bazooka to a knife fight.The most robust-looking alternative I’ve found is vhtml (from the creator of Preact), but it doesn’t seem that actively maintained. Then again, if it’s doing one thing and doing it well, maybe it doesn’t need to be.
Yeah honestly if you want to “just” output the HTML, you can write a thing yourself. There’s not really much to do, and any lib will be feature complete extremely quickly. The “maintenance question” should not hold you back from using something like vhtml!
FWIW, I think JSX was more inspired by PHP than E4X. React was built by Facebook, for Facebook, which was sitting on a very large PHP/Hack codebase.
E4X was probably also inspired by PHP, but it was focused on using XML as a data format more than as a rendering target. I miss using it in ActionScript, TBH. In React it’s very easy to make nested components, but querying the tree is very difficult. E4X was all about querying the tree! And it was typesafe IIRC, at least in AS3 — the compiler could parse XML and make sure your queries actually would return what you wanted, assuming you were using static XML files for config.
Of course, today you can statically check your JSON configs with TypeScript, but sometimes JSON just isn’t the right config language — for example, writing dialogue trees in games in XML is easy, but you’re gonna want a wrapper tool or UI for it in JSON or you’ll go insane escaping characters by hand.
So JSX is PHP now?