Vue · Senior · Question 72 of 75

How do you keep the initial value of a prop as local editable state without warnings?

const props = defineProps<{ initialTitle: string }>()
const title = ref(props.initialTitle)

Explanation

Later prop changes won't update the copy; if they should, watch the prop or use defineModel instead.

Further reading

Problem with a question

Vue · Senior · question 72

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