React · Junior · Question 16 of 75

Which value is best for key in a list?

Explanation

key helps React match elements between renders. An index breaks on insertion, removal and sorting: input state and DOM "move" to other items. A random key changes every render - React recreates all elements and loses their state.

Further reading

Problem with a question

React · Junior · question 16

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz