React: Why index can't be Key of react element (in arrays)

Created on 21 May 2018  路  3Comments  路  Source: facebook/react

So Why index can't be Key of react element (in arrays).

Thanks.

Most helpful comment

All 3 comments

It's a bad idea to use the array index since it doesn't uniquely identify your elements. In cases where the array is sorted or an element is added to the beginning of the array, the index will be changed even though the element representing that index may be the same. This results in unnecessary renders.

https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md

Hey there! We use the issue tracker for bug reports and feature requests.

If you have a question, please check our community support resources:
https://facebook.github.io/react/community/support.html

Was this page helpful?
0 / 5 - 0 ratings