Why does React need a key prop when rendering a list of elements?
Correct answer
A. To identify items so updates are efficient
18 views
A. To identify items so updates are efficient
18 views
Keys let React's reconciliation match items between renders, so it can reorder, add or remove only what changed. Stable IDs work best. Array indexes can cause bugs when the list order changes.
Asked in: React Interviews, Frontend Developer Tests
Not sure why the answer is A? Ask here and get an explanation.