How do you loop inside JSX? in REACT

Practice



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

  {items.map(item => )}

You cannot iterate using a for loop:

 
  for (let i = 0; i 
  }

This is because JSX tags are transformed into function calls, and you cannot use statements inside expressions. This may change thanks to do expressions, which are a stage 1 proposal

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Scripting client side JavaScript, jqvery, BackBone"

Terms: Scripting client side JavaScript, jqvery, BackBone