-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Improve description of "disconnected" property caveat to reactive obj… #2202
Conversation
…ects. Try and make more clear what happens when you create a new reference to a reactive object property. Just saying "disconnected" is ambiguous and confusing because as stated else where in the docs, reactivity is "deep", so the property your referencing is actually still a proxy object. It's just "disconnected" from the parent to subscribers to the parent will not get notified. At least that is my understanding of what is going on (it's strange because it seems like have a parent reference would be a simple fix to this issue, but that has not been done for some unexplained reason).
✅ Deploy Preview for vuejs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
We can certainly try to improve the wording of that paragraph. I'm not sure whether the wording you've proposed quiet works though. Feedback below.
@@ -104,7 +104,7 @@ Code snippets here and below are meant to explain the core concepts in the simpl | |||
|
|||
This explains a few [limitations of reactive objects](/guide/essentials/reactivity-fundamentals.html#limitations-of-reactive) that we have discussed in the fundamentals section: | |||
|
|||
- When you assign or destructure a reactive object's property to a local variable, the reactivity is "disconnected" because access to the local variable no longer triggers the get / set proxy traps. | |||
- When you assign or destructure a reactive object's property to a local variable, the local variable's reactivity is "disconnected" from the parent object because access to the local variable no longer triggers the get / set proxy traps on the parent object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this wording. I think it implies that the value of the property is also an object. The value could be anything. The phrase 'parent object' makes sense if there is also a child object, but I'm not so sure whether it works for values more generally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback
The phrase 'parent object' makes sense if there is also a child object, but I'm not so sure whether it works for values more generally.
I can't see it. I think the phrase makes sense if there is a parent object, regardless.
I'd agree, the gotcha here for me is all about when the child is an object or array (a reference type). In my thinking if you destructure or assign a primitive value it seems obvious that the new variable will not be reactive - how can it be. But the case of a ref type (array or object) is much more confusing because the thing is still a Proxy object, it's just disconnected.
Just did a bit of testing and I'm confused about what the original document meant by:
The watcher is triggered. Doesn't that imply "a" the local variable is not "disconnected" after all? In any case, agree the statement needs clarifying but this PR is probably not good for that. |
It is disconnected in the sense that if you use
I think this is ultimately the cause of the confusion. To you this seems obvious, but to many people it isn't obvious and needs stating explicitly. For someone new to Vue it isn't necessarily obvious quite how reactivity and |
I'm confused. I think you saying the reference to
True. Happy to state explicitly about primitives. Nothing to me is very obvious about reactive in Vue :). |
…ects.
Try and make more clear what happens when you create a new reference to a reactive object property. Just saying "disconnected" is ambiguous and confusing because as stated else where in the docs, reactivity is "deep", so the property your referencing is actually still a proxy object. It's just "disconnected" from the parent to subscribers to the parent will not get notified. At least that is my understanding of what is going on (it's strange because it seems like have a parent reference would be a simple fix to this issue, but that has not been done for some unexplained reason).
Description of Problem
Proposed Solution
Additional Information