hasChanged behavior in the Vue 3.4 reactivity system #11193
Replies: 3 comments 7 replies
-
There are several problems with this example, but the main problem is that If you modify non-reactive data then Vue's behaviour is undefined. It might work, it might not. This isn't something that is guaranteed to stay the same between versions. |
Beta Was this translation helpful? Give feedback.
-
As mentioned in another thread: This computed sorts someArray in place, which means it always returns the same reference. Since 3.4 computeds have become lazy. If the result is equal (as in this case, given it is the same reference) it will not trigger deps. Solution may be to return a new array when using the sort function, using return [...sortedItems] in the computed. |
Beta Was this translation helpful? Give feedback.
-
Hi. I have a scenario that has a different outcome in different versions of vue!
In vue 3.3 the computed, watch, and render are triggered and the array is changed.
In vue 3.4 the computed is triggered but watch and render do not!
I think this is some sort of BREAKING CHANGE behavior if it is not a bug. I know that 3.4 is checking for reference and if I do [...sortedItems] it will work the same, but if the current code works differently in different versions of vue it may be a breaking change!
This scenario is related to this #5912 PR and I'm not sure if this is a bug, a breaking change, or just an expected behavior!
Beta Was this translation helpful? Give feedback.
All reactions