-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using the deep
mode of watch
, watchCallBack
will be triggered even if the value does not change.
#7160
Comments
Computed properties are lazily evaluated. So to know wether or not their value ha changed, the need to be read by some code. So effects depending on a computed property need to run in order to find out wether the return value has changed. details: https://dev.to/linusborg/vue-when-a-computed-property-can-be-the-wrong-tool-195j |
I also found this, but it doesn't explain why turning on Inside const needCallback = options.deep && typeof newValue === 'object'
? true
: oldValue !== newValue |
Thanks for the reply, I think I misunderstood your report. Reopened to investigate. |
…ill be triggered even if the value does not change (fix vuejs#7160)
Fixed by #5912 |
Vue version
all (>=v3.2.16)
Link to minimal reproduction
Steps to reproduce
Link to minimal reproduction
What is expected?
Do not call
watchCallBack
if the value has not changed; for example, ifwatch
is listening for changes to an object incomputed
and the object's value isundefined
for the next few changes, thenwatchCallBack
should not be triggered.The current behavior of
watch
in the above case leads to some hidden vulnerabilities that are hard to debug.What is actually happening?
When using the
deep
mode ofwatch
,watchCallBack
will be triggered even if the value does not change.System Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: