[@vue/compiler-sfc] "xxx" is a destructured prop and should not be passed directly to watch()
Vue version
3.3.0-alpha.6 3.3.0-alpha.7
Link to minimal reproduction
Steps to reproduce
Open reproduction url and select vue version 3.3.0-alpha.6 or alpha.7 (for some reason SFC Playground doesn't remember the selected version)
What is expected?
Should compile vue component without error since all code is valid.
What is actually happening?
Compiler throws an error:
Error: [@vue/compiler-sfc] "error" is a destructured prop and cannot be directly watched. Use a getter () => error instead.
App.vue
13 | const { error } = useRequest();
14 |
15 | watch(error, () => {
| ^^^^^
16 |
17 | });
But if you remove const { userId } = defineProps({ userId: Number })
then the error is gone.
According to the @vue/compiler-sfc error message, you can use it like this
const { error } = useRequest();
watch(() => error, () => {
});