5

I want to loop an array and create list items out of it. In the console,it is showing mistake is thrown, because my array has no keys but only values. So What is the right operation to read out an array?

*// this.props.items = ["cars","streets","houses"];*Wrong. You can't update props

var TodoList = React.createClass({
 render: function() {
  var createItem = function(item) {
  return <li>{item}</li>;
  };
  return <ul>{this.props.items.map(createItem)}</ul>;
}
});
Ved
  • 11,837
  • 5
  • 42
  • 60
user1477955
  • 1,652
  • 8
  • 23
  • 35
  • 2
    keys are required in your `
  • `s and they can be anything but should be unique for each child. http://stackoverflow.com/a/28329550/1642219
  • – Udit Bhardwaj Mar 08 '16 at 07:24