6 ms·
I don't mind a pre-compilation step as I'm already doing it in my projects and a lot of the community is as well. There are other templating systems you can us
by pests 8y ago
I don't mind a pre-compilation step as I'm already doing it in my projects and a lot of the community is as well.
There are other templating systems you can use in React if you don't like JSX.
I've seen one codebase use direct calls to ReactDOM.createElement and there is a new hotness (which I can't think of the name of now) that replaces JSX with template literals, something like:
function NamePetList(props) {
return html`
<div>
Hello <b>${props.name}</b>!
<ul>
${props.pets.map(pet => html`
<li ${...pet.props}>${pet.name}</li>`
}
</ul>
</div>
`
}
which I really like.
The library parses the strings to figure out which elements to create. Flow control and variables are just normal template literal arguments.
- sophiebits 8y agoYou're likely thinking of https://github.com/developit/htm https://github.com/developit/htm.
- pests 8y agoOh yes! Thank you.
- reificator 8y agoI get the pros and cons of jsx/htm (and hyperhtml/lithtml) just fine. I'm just saying that bringing up React as an example of a framework that should not be treated as a new language is not the best possible example, since it does literally come with a new language.