DEV Community


Posted on • Updated on

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

• 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.


Discussion (0)