How to loop inside JSX?

Posted by Prem Tiwari | Updated on

How to loop inside JSX?

You can simply use with ES6 arrow function syntax. For example, the items array of objects is mapped into an array of components:

But you can’t iterate using for loop:

This is because JSX tags are transpiled into function calls, and you can’t use statements inside expressions. This may change thanks to do expressions which are stage 1 proposal.

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@] Your question and answer will appear on and help other developers.

Related Questions & Answers