Vue · props
vite-doctor/vuepropserrorNo fix
Why it happens
Props belong to the parent. Vue rejects a direct write such as props.count++ in development, and in production the parent's next render overwrites it. A deep write such as props.user.name = 'x' silently changes the parent's object.
Fix
Emit an event or use defineModel() so the parent applies the change, or copy the prop into local state when the child needs its own editable value.
Example
Let the parent own prop updates
Before
<script setup lang="ts">
const props = defineProps<{ user: { name: string } }>()
function rename(name: string) {
props.user.name = name
}
</script>
After
<script setup lang="ts">
const props = defineProps<{ user: { name: string } }>()
const emit = defineEmits<{ rename: [name: string] }>()
function rename(name: string) {
emit('rename', name)
}
</script>
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --framework vue --rules vue/props/no-mutating-props