-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Unexpected update on app.vue caused by calling computed on mounted #9046
Comments
I found the problem on this.childProp. Anything that affects this variable will trigger the updated. So I define a variable containing the value of childProp on Data line #24, and it solve the problem. |
Thanks @TDSkyz, hmm, but this still does not make sense to me. Why calling the computed function in |
In lifecycle.js lines316 , the method 'callHook', disable dep collection when invoking lifecycle hooks by 'pushTarget()', which means the dep collection will be useless in the lifecycle method. The principle of this is that when pushTarget(), the params--watcher is 'undefined', so in the lifecycle method--mounted, Dep.target is 'undefined', which means will not run dep collection. |
Version
2.5.17
Reproduction link
https://jsfiddle.net/je3odvk8/
Steps to reproduce
Try click "parent button" which update the parent component's data, but I don't understand why this causes app to update. But if you remove the line #32 console.log(this.childName), this won't happened.
What is expected?
Expected only updating the Parent component and Child component when data updated on the Parent.
What is actually happening?
App updated caused by a child component when having console logging the computed data
The text was updated successfully, but these errors were encountered: