Reputation: 115
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'
Upvotes: 7
Views: 19523
Reputation: 1593
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")
);
Upvotes: 15