💡 Rendering stops after all list items are processed and React updates the DOM.
Variable Tracker
Variable
Start
After 1
After 2
After 3
Final
items
['apple', 'banana', 'cherry']
Same
Same
Same
Same
key prop
undefined
undefined
undefined
undefined
defined or index depending on fix
Key Moments - 3 Insights
Why does React warn about missing keys in list items?
React uses keys to identify which items changed, added, or removed. Without keys (see execution_table rows 2-5), React cannot track items properly and may re-use DOM elements incorrectly.
Is using the array index as a key always safe?
Using index as key (see execution_table rows 8-9) works if the list never changes order or items. But if items reorder or change, React may update wrong elements, causing bugs.
What happens if keys are not unique?
If keys are duplicated, React cannot distinguish items properly, leading to unexpected UI updates or bugs. Keys must be unique among siblings.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table at step 3. What is the key prop value for the 'banana' item?
AIndex 1
BNo key prop present
C'banana'
D'apple'
💡 Hint
Check the 'Key Prop Present?' column at step 3 in the execution_table.
At which step does React start using keys to track list items correctly?
AStep 6
BStep 5
CStep 8
DStep 2
💡 Hint
Look for the first step where 'Key Prop Present?' is 'Yes' and React behavior improves.
If you use index as key (step 8), what problem might occur when the list changes?
AReact will throw an error
BReact will ignore the list
CReact may update wrong items causing UI bugs
DReact will duplicate items
💡 Hint
Refer to the React behavior described at step 9 in the execution_table.
Concept Snapshot
React list rendering requires a unique key prop on each item.
Keys help React track items between renders.
Missing keys cause warnings and inefficient updates.
Using array index as key can cause bugs if list order changes.
Always use stable, unique keys like IDs or unique strings.
Full Transcript
This lesson shows how React renders lists by mapping over arrays and returning JSX for each item. React requires a unique key prop on each list item to track changes efficiently. Without keys, React warns and may re-use DOM elements incorrectly. Using array index as key works only if the list never changes order. Unique, stable keys prevent UI bugs and improve performance.