-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Added explanation when "props" in components are reactive #862
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
Conversation
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.
Thank you for your feedback!
LGTM 👍
/ping @chrisvfritz @yyx990803
Please check it!
Thanks for the PR - however, I feel this isn't quite accurate and may actually cause more confusion... This is what is actually happening:
|
@kazupon & @yyx990803 thanks for your feedback! @yyx990803 your points are very good of course, thanks for explaining! The question is whether we can improve the PR up to a point where it makes sense to everyone. My motivation here stems from two observations:
Is this worth explaining? How can we correct the PR, am I wrong assuming that if you save an |
If you want the prop to be reactive why not just use it directly? Why do the initialize in data -> watch dance? |
I feel there can be a conflict of best practices for the 2nd scenario I describe - on one hand we are telling people
On the other hand in the 2nd scenario you want the This at least is my humble undestanding. |
@balint42 the more idiomatic way to handle that is emitting an event to the parent and let the parent mutate the state. |
@yyx990803 we are quite deep into this specific
(of course phrased cleaner with examples as in the PR) |
@balint42 your understanding is still a bit off. I'll try to clarify:
|
This sounds like it may not be Vue-specific, but more a general source of confusion in JavaScript regarding how objects and arrays work. Since it does affect many users however, I think it could be good to do a blog post or cookbook recipe on it (I just added it to our todo list). This snippet from a curriculum I use for teaching JavaScript may help explain some of why you see the behavior you do in Vue - and in JavaScript. |
This is a proposal for extending the docs with detailed explanations about when
props
are reactive. It originated from the forum discussion created for this purpose.Please review my points carefully and let me know about mistakes I have made or possible improvements to the content.