Problem Statement
How does the key prop help React in render optimization?
Explanation
Keys help React identify which elements changed, added, or removed in a list. This allows React to re-render only the modified items instead of the whole list, improving performance.
Code Solution
SolutionRead Only
{items.map(item => <li key={item.id}>{item.name}</li>)}Practice Sets
This question appears in the following practice sets: