Warning: Each child in an array or iterator should have a unique "key" prop.
2017-05-29 16:40
459 查看
源代码是这样
但会报这样的错误:
解决方案如下:
class Main extends Component{ render(){ return( <div> { arr.map((item,index)=>{ return( <li>{item*2}</li> ) }) } </div> ) } } render( <Main />, document.getElementById("root") );
但会报这样的错误:
bundle.js:1004 Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `Main`. See https://fb.me/react-warning-keys for more information.
解决方案如下:
class Main extends Component{ render(){ return( <div> { arr.map((item,index)=>{ return( <li key={index}>{item*2}</li> ) }) } </div> ) } } render( <Main />, document.getElementById("root") );
相关文章推荐
- Warning: Each child in an array or iterator should have a unique "key" prop.
- Warning: Each child in an array or iterator should have a unique "key" prop. Check the render ...
- react-native中debug报错信息:Each child in an array or iterator should have a unique "key" prop.
- Warning: Each child in an array or iterator should have a unique “key” prop. Check the render method
- React总结7:Each child in an array or iterator should have a unique "key" prop.的处理方法
- react Warning: Each child in an array or iterator should have a unique "key" prop. Check the render
- Each child in an array or iterator should have a unique "key" prop. Check the render method of `Tabl
- ReactNativeiOS(三)开发零碎3 warning: Each child in ar array or integrator should have a unique "key" prop
- ant-design Warning: Each record in table should have a unique `key` prop,or set `rowKey` to an un
- Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.
- Defining <uniqueKey> as a "long" or "int" type throws an error on startup
- Warning: array_merge() [function.array-merge]: Argument #2 is not an array in e\\class\\functions.php on line 2193
- Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?an
- jQuery数组($.each,$.grep,$.map,$.merge,$.inArray,$.unique,$.makeArray)处理函数详解
- Warning message in work center (" Factory calender and shift model have different working days".)
- 解决报错"Your security system have blocked an application with expired or not yet valid certificate from running"
- Ruby: Count unique elements and their occurences in an array
- ./configure时 You have an outdated FFmpeg SVN checkout in ffmpeg/, please (re)move or replace it
- jQuery数组($.each,$.grep,$.map,$.merge,$.inArray,$.unique,$.makeArray)处理函数详解
- 在使用Navicat for MySQL 出现 异常"You have an error in your SQL syntax......"