1

Can someone please clarify why this render function

var ListItemWrapper = React.createClass({
  render: function() {
    var renderMe = [
      <span>{this.props.data.id}</span>,
      <span>{this.props.data.text}</span>
    ];

    return <div>{renderMe}</div>;
  }
});

generates

Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of ListItemWrapper. See fb.me/react-warning-keys for more information.

and this one is good with no warnings:

var ListItemWrapper = React.createClass({
  render: function() {
    var renderMe = (
      <p>
        <span>{this.props.data.id}</span>
        <span>{this.props.data.text}</span>
      </p>
    );

    return <div>{renderMe}</div>;
  }
});
user6213384
  • 135
  • 1
  • 1
  • 9
iurii
  • 4,142
  • 2
  • 23
  • 28
  • 3
    In the first example you are using an array, in the second example you don't. Did you follow the link? What is still unclear? – Felix Kling Nov 15 '15 at 00:21

0 Answers0