Vue · Junior · Question 29 of 75
Why shouldn't a child mutate a prop?
- ✓Correct answer: Props follow one-way data flow: the parent owns the value, and Vue warns about mutations
- 2Props are frozen with
Object.freeze, so mutation throws - 3Mutation is allowed and updates the parent
Explanation
If the child needs to change the value, emit an event so the parent updates it, or copy the prop into local state if it's only an initial value.