Vue · Senior · Question 12 of 75

How can changing the key of a component be used intentionally?

<UserForm :key="user.id" :user="user" />

Explanation

A new key means a new component instance. It is a simple way to reset forms when switching entities, at the cost of recreating the subtree.

Further reading

Problem with a question

Vue · Senior · question 12

Test yourself

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

Take this quiz