React · Senior · Question 45 of 75

How does key on a wrapper component differ from key inside a list?

Explanation

key is part of a component's identity anywhere. In a list it matches items between renders; outside a list it's used to explicitly reset state (<Chat key={contactId} />). The key must be unique among siblings, not globally.

Further reading

Problem with a question

React · Senior · question 45

Test yourself

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

Take this quiz