关于react循环渲染中的key

在react中使用map或者其他方法生成DOM时经常看到如下警告:

index.js:1446 Warning: Each child in an array or iterator should have a unique "key" prop. See https://fb.me/react-warning-keys for more information.

这是因为我们没有为其绑定一个key={}造成的,关于key的作用:

https://reactjs.org/docs/lists-and-keys.html

更深入的解释:

https://react.docschina.org/docs/reconciliation.html#

使用了索引作为key后可能造成的副作用:

https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318