If a object from deconstruct can't be watch even thought it is a proxy object? #11333
Replies: 3 comments 3 replies
-
This might be related to this [PR] #7986
|
Beta Was this translation helpful? Give feedback.
-
This is confused for me too, which is the reason why I do not like the destructure props feature. You can try: isReactive(tableData) // = true So |
Beta Was this translation helpful? Give feedback.
-
Not sure if you figured it out already, but I asked an AI about this and here's what I learned: This error happens because the Vue compiler can't tell whether the variable you passed to watch (after destructuring from defineProps) is still reactive or not. Even if it's obvious to you as the developer, the compiler can't safely assume it, so it prevents you from using it directly. Instead, you should wrap it in a getter like () => tableData or use toRef(props, 'tableData') to make the reactivity explicit. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
playground
why can't write like this
`
// change watch tableData in comp.vue not a getter
watch(tableData,(val)=>{
console.log(val,'watch')
},{immediate:true})
`


in the playground ,I printed it.It is a proxy ,right? So,the tableData from Deconstruct is still reactivity proxy
This is a force rule?😢
Beta Was this translation helpful? Give feedback.
All reactions