DEV Community

Discussion on: The React Cheatsheet for 2020 📄 (+ Real-World Examples)

Collapse
 
ulubayam profile image
Gizem Ulubayam

Hi, great article. Thank you for your effort. You say list and keys section "use array element index for key" but this is not a good idea. Because when you use an index of an array as a key, React will optimize and not render as expected and also it is an anti-pattern. I just wanted to specify. Have a nice day.

Collapse
 
oziniak profile image
Oleh Ziniak • Edited

As long as you do not reorder or delete any items, indexes are ok. It's ok even if you add items to the end, or always delete the last one.

Collapse
 
ulubayam profile image
Gizem Ulubayam

Yes, you are right. It can only be missed on a large-scale project. So I wanted to specify.

Collapse
 
reedbarger profile image
Reed Barger • Edited

I mention that a unique id is better.

Collapse
 
ulubayam profile image
Gizem Ulubayam • Edited

Ok. I must have missed. Thank you.