6
    var divArr = [
       '<div>布吉岛啊</div>',
       '<div>呵呵呵</div>',
    ];
    ReactDOM.render(
       <div>{divArr}</div>,
       document.getElementById("example")
    );

but it's error:

Warning: Each child in an array or iterator should have a unique "key" prop. Check the top-level render call using . See [warning-keys][1] for more information.

and I don't know how to insert the 'key'

Community
  • 1
  • 1
Shyla Nie
  • 105
  • 1
  • 1
  • 5
  • Possible duplicate of [Understanding unique keys for array children in React.js](http://stackoverflow.com/questions/28329382/understanding-unique-keys-for-array-children-in-react-js) – Nier Aug 29 '16 at 04:07

1 Answers1

14

you need to put unique key inside the array div check my code

var divArr = [
 '<div key='1'>布吉岛啊</div>',
 '<div key='2'>呵呵呵</div>',
];
ReactDOM.render(
   <div>{divArr}</div>,
   document.getElementById("example")
);
Md.Estiak Ahmmed
  • 1,553
  • 9
  • 14