Vue · Watchers

VUE0050Watch a reactive property through a getter

Finds direct property reads passed as a `watch()` source or as an entry in a source array, when the property is known to hold a primitive. Doctor looks at `defineProps()` declarations and local `const` objects initialized with `reactive()` and a literal. It leaves refs, getter functions, intentional deep watches of reactive objects, and unresolved values alone. Destructured props are covered by `vue/reactivity/defineprops-watch-getter`.

Why it happens

watch(props.userId, cb) evaluates props.userId once and passes its current value. A primitive is not a valid watch source, so Vue cannot subscribe to changes to the property. A getter lets Vue track the property read and run the callback when the value changes.

Fix

Pass a getter, watch(()` => props.userId, cb)`. In a source array, wrap only the primitive property read: watch(()` => props.userId, otherSource, cb)`.

Example

Watch a prop through a getter

Before

<script setup lang="ts">
import { watch } from 'vue'

const props = defineProps<{ userId: string }>()

watch(props.userId, (id) => loadUser(id))
</script>

After

<script setup lang="ts">
import { watch } from 'vue'

const props = defineProps<{ userId: string }>()

watch(() => props.userId, (id) => loadUser(id))
</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/watch/no-property-read-source
Copyright © 2026