you can actually write for loop in render, but you need to do it outside of return

the reason for this is, return and jsx only accept expression,

which mean you need to have something like this

<A>{must be an expression}</A>

what is expression? an expression is value or statement that can be evaluated into value, since for loop cannot be evaluated into value, hence error

however map or forEach can be evaluated into value (forEach can only evaluate into undefined btw), you can write map or forEach in jsx

the same reason why you cannot do if else in jsx but you can do ternary operator, because if else cannot evaluate in value while ternary can

--

--

Typescript Zombie. Youtube Pikachu On Acid. (Unrelated to programming but by watching it you become a good developer overnight)

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Acid Coder

Typescript Zombie. Youtube Pikachu On Acid. (Unrelated to programming but by watching it you become a good developer overnight)