React tldr; Why Do I Need Keys in React List?

maniekm profile image Mariusz Updated on ・1 min read

• Lists are performant heavy and need to be used carefully.

• Make sure every item in the list has a unique key.

• It is preferred to not use indexes as a key unless you know for sure that the list is a static list (no additions/re-ordering/removal to the list).

• Never use unstable keys like Math.random() to generate a key.

• React will run into performance degradation and unexpected behavior if unstable keys are used.

Source: https://medium.com/@adhithiravi/why-do-i-need-keys-in-react-lists-dbb522188bbb?fbclid=IwAR09xviOqDHRc7gvvoLXXDgVfVBtxbkCylq0p2Eur-jKrhw9EuMIpZ7c0BQ


markdown guide