警告:Warning: Each child in an array or iterator should have a unique "key" prop

@ckinmind 2017-01-07 02:36:56发表于 ckinmind/ReactCollect

出错代码:

 <div id="example"></div>
    <script type="text/babel">
      var arr = [
        <h1>Hello world!</h1>,
        <h2>React is awesome</h2>,
      ];
      ReactDOM.render(
        <div>{arr}</div>,
        document.getElementById('example')
      );
    </script>

错误信息:

react.js:19287 Warning: Each child in an array or iterator should have a unique "key" prop. Check the top-level render call using

参考资料1:Warning: Each child in an array or iterator should have a unique “key” prop
参考资料2:segmentfault