If I inspect a computed property in Vue 2.7, I can see that, besides the well-known .value
property, there's also .effect
. I wasn't able to find any information about it, except that it's deprecated in Vue 3. Does anybody know why it was needed and what its use was? Why has it become deprecated? I'd also appreciate, if somebody shares a link to the page where this property would be documented.
If I inspect a computed property in Vue 2.7, I can see that, besides the well-known .value
property, there's also .effect
. I wasn't able to find any information about it, except that it's deprecated in Vue 3. Does anybody know why it was needed and what its use was? Why has it become deprecated? I'd also appreciate, if somebody shares a link to the page where this property would be documented.
- Looks like it's an old API that was considered when migrating towards the v3. Was probably deprecated in favor of watchEffect. – kissu Commented Nov 18, 2024 at 14:46
1 Answer
Reset to default 1It's an undocumented API for internal purposes that contains a watcher that updates the computed value:
some libs rely on the presence effect for checking computed refs from normal refs, but the implementation doesn't matter
This seems plausible, because in Vue 3 computed and other special kinds of refs have internal properties that make them different from regular refs, but they don't exist in Vue 2 reactivity API.
In Vue itself, it's used for testing.