Scoped component not updating properties on parent changes #228
Replies: 5 comments 5 replies
-
try reactive:
|
Beta Was this translation helpful? Give feedback.
-
@sqllyw that doesn't make any sense, that would only make specific on-the-fly array of items book items reactive, not the actual books_1. And even then, this is just a property that gets passed down to Library. (anyways i did try to use |
Beta Was this translation helpful? Give feedback.
-
ok, the issue seems related to the Book component, when you change the book in :
v-scope="Book({title:book.title})" is still referring to the value that you passed from books_1, because props are not responsive, this is very similar to #109, the selected answer in 109 explains why, and also offer a solution, to apply to your example:
as for why this works:
your comment already explains it. |
Beta Was this translation helpful? Give feedback.
-
in your example, the Book component got passed a primitive value, if you change the books_1[0].title it will not be reflected since primitive data is non reactive by design, you can pass a object, then change the object properties, it is reactive, here is a slight change to your code that illustrate this point, you can still have a good code manageability by passing a book object to the Book component:
a working sample here: |
Beta Was this translation helpful? Give feedback.
-
You can add |
Beta Was this translation helpful? Give feedback.
-
Hello,
could please someone explain what am i doing wrong?
I have a parent component, let's say "Library", iterating over array of children, let's say "Books". However, when i update the children Books array petite vue doesn't catch its changes, only if i delete the array, wait a bit/on next tick, and then re-assign the books again.
But then again, it catches the change when i just
.concat()
the arrayThis is the full (non) working example to explain what i mean:
What is going on here? What am i doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions