3 ms·
Sure, but it maps 100% to an expected JS syntax and improves readability (subjective). From <div attr1="str">{children}</div> To React.createElement("div", { a
by veidelis 5y ago
Sure, but it maps 100% to an expected JS syntax and improves readability (subjective).
From
<div attr1="str">{children}</div>
To
React.createElement("div", { attr1: "str" }, children)
Custom templating is not like that.
- toastercat 5y agoSubjective indeed. If the goal is to leverage the full expressiveness of JavaScript, you could just alias React.createElement to something like `h`. Or use something like https://github.com/caderek/react-plain https://github.com/caderek/react-plain
- jeswin 5y agoYeah, but that's harder in practice. You often copy html snippets into your code, for example from tailwind or bootstrap samples. This is easier in JSX syntax; you'd just need to copy and fix up some attribute names.
- toastercat 5y ago> You often copy html snippets into your code, for example from tailwind or bootstrap samples. This is easier in JSX syntax; you'd just need to copy and fix up some attribute names. I literally never do this, but I suppose there are people who use React/JSX as a glorified templating library. Even then I probably wouldn't do this and rather use a proper templating library where HTML is valid.
- Kiro 5y agoIt's very common if you're working with Tailwind (since the markup is self-contained). No need to be condescending.
- toastercat 5y agoSorry, I did not mean to be condescending. I do use Tailwind, but even then I don't really copy-paste HTML examples.