kanashin
kanashin

Reputation: 365

VueJS: Updating a parent object won't be reflected on child

I have a parent with an object data and I sent to the child part of it. I hope that when the parent is updated the child should be updated to.

groupProps is an object that every property has a lines array. In example: groupProps[1].lines[3] can exist.

<nova-grup v-for="group in m.groups"
           :group="group"
           :groupProp="groupProps[group.id]"
>
</nova-grup>

The first time it's working fine. The problem is when groupProps is changed the child isn't. For example, when changing or adding a line to groupProps.lines.

I have also noted that any computed variable based on the object isn't updating neither. Is this a limitation of vuejs? I'm using some lodash functions inside the computed variable

Upvotes: 2

Views: 438

Answers (1)

kanashin
kanashin

Reputation: 365

OK, it is a limitation.

https://v2.vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats

Finally I solved it doing this.myvar = Object.assign({}, this.myvar );

Upvotes: 1

Related Questions