Update Vue 3 Component Props Value Correctly Using Composition API

Vue 3 props are one-way and immutable. Use v-model or emit events in the Composition API so that the parent updates and passes new prop values.

Summarize with AI

Not enough time? get the key points instantly.

In Vue.js development, props are designed for one-way data flow: data flows down from a parent component to a child component. This principle helps keep your application’s data predictable and traceable.

Attempting to directly change a prop’s value within the child component is considered an anti-pattern and will trigger a warning in development mode (“Attempting to mutate prop ‘propName’. Props are immutable!”).

Why Direct Prop Mutation is Discouraged

Directly changing a prop in a child is bad because it:

  • Confuses Data Origin: Hard to know where changes come from.
  • Causes Side Effects: Can unexpectedly affect other parts of your app.
  • Triggers Vue Warnings: Vue helps you avoid this anti-pattern.

Correct Ways to “Update” a Prop from a Child Component

To “update” a prop from a child, the child needs to tell its parent. The parent then updates its own data, which correctly flows down as a new prop. This is the “prop down, event up” pattern.

1. Prop Down, Event Up with v-model (Recommended)

This is the standard and most robust way to handle prop updates. The child component emits an event, passing along the new value. The parent component listens for this event and updates its own state, which then correctly flows down to the child as a prop.

  

 

 

  

{{ props.title }}

  

2. Using a Local Data Copy (for Initial Values)

If the prop is just for an initial value, and the child manages its own state independently afterward.

  

    

Local Count: {{ currentCount }}

    

  

 

Also Read: Vue Component Libraries to Build Stunning Frontends

3. Using a computed Property (for Derived Values)

If you need a value that’s a calculation or transformation of props. computed properties automatically update when their source props change.

  

    

Total Cost: ${{ totalCost }}

  

 

Also Read: Vue 3 Composition API data() Function

Key Takeaway

Never directly change a prop in a Vue 3 component. Always use the “prop down, event up” pattern (especially with v-model for forms) to let the parent handle updates. For internal state or derived values, use ref (with optional watch) or computed properties. This maintains clear and predictable data flow.

Related Resources


Resources

Insights from our engineering leaders.

Our team shares practical insights on the technologies and engineering decisions shaping enterprise software today, grounded in real client work.