8 ms·
knowing both i used to be frustrated by jsx's lack of support for plain if and for loops like razor has (eg map and the weird && syntax we general end up with)
by _betty_ 3y ago
knowing both i used to be frustrated by jsx's lack of support for plain if and for loops like razor has (eg map and the weird && syntax we general end up with)
eg
```
<ul>
@foreach(var item in list) {
<li>@item.name</li>
}
</ul>
```
of course this idea goes against jsx's implementation (as it's just nested functions) and paradigm of being html in plain javascript rather than an interpreted templating language.
some of the differences i really like (like being able to assign compoents to variables, pretty sure razor doesn't have anything like that).
- javcasas 3y agoThe thing about jsx is that I don't have to learn the special syntax and rules that govern the @foreach construct. jsx map accepts a js function which should return a jsx element. Can I use...? If it works in js, yes.
- _betty_ 3y agoForeach in razor is just c# too, so it's not a language thing it's more what it transpiles to.