I am trying to watch a prop in Vue 3 but it is strange that when I destructure it then the watcher doesn't work. But without destructuring it works as expected. What am I missing here?
P.S. I am using Vue 3 + Vite
This is not working
export default {
props: {
modelValue: {
type: Boolean,
default: false,
},
},
setup({ modelValue }, context)
{
watch(() => modelValue, (newValue, oldValue) => {
console.log(newValue)
})
},
}
But if I don’t destructure it then it works
setup(props, context) {
watch(() => props.modelValue, (newValue, oldValue) => {
console.log(newValue)
})
}
