-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix(reactivity): ref as a reactive parameter should return (#6358) #6359
Conversation
The title of this PR is currently a bit misleading. It refers to an earlier iteration of the code, but the code has changed significantly since then. Some notes for reviewers... There's another PR, #6376, that attempts to fix the same problem. They take very different approaches, so I've written a brief comparison here. The original problem occurs with this code: import { reactive, ref, effect } from 'vue'
const a = reactive(ref(1))
effect(() => {
console.log(a.value)
})
a.value++ The effect ends up with 3 dependencies, so when the value changes to 2, it will trigger the effect 3 times. The dependencies are:
The approach in #6376 is to remove the proxy before accessing The approach in this PR is a bit different. It skips tracking in the proxy if the underlying value is a ref. That avoids dependencies 2 and 3 from the list above, so the effect is only triggered once. This does also mean that the proxy will no longer track any other properties of the ref, not just |
Size ReportBundles
Usages
|
commit: @vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
|
This is no longer needed in 3.5 after 313e4bf |
fix: #6358
It need to wait for #11696 to be fixed