4
votes
    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'

1

1 Answers

6
votes

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")
);