← React Field Guide
Concept 8 of 11
Lists
✦ Tap any highlighted term to learn more
When you have an of data and want to a list of UI elements from it, use the .map() method. It transforms each item in the into a piece of .
Every item in a list must have a unique key . The key must be a string or number that uniquely identifies that item among its siblings — usually an ID from your data.
React uses keys to track which items have changed, been added, or been removed between . Without keys, React has to guess — which causes bugs with ful list items and is slower.
Don't use the index as a key if your list can be reordered or filtered. Index keys cause subtle bugs because the key stays the same even when a different item is at that position. Use a real ID when you have one.