React·100 questions

Why is the key prop needed in lists?

Answer
key helps React match elements between renders.
Speeds up diff and reduces bugs.
key should be stable, not an index (if list changes).
Better to use id from data.
Incorrect key causes 'jumping' state.
Was this answer helpful?

More questions in this topic

Related questions from other topics