Back
VueMediumNew

What are some key differences in reactivity caveats between Vue 2 and Vue 3?

Vue.set, array index reactivity

Ideal Answer

In Vue 2 (using Object.defineProperty), several reactivity limitations existed:

  • Adding a new property to an object after creation wasn't reactive unless added via Vue.set(obj, key, value).
  • Setting an array index directly (arr[0] = val) or changing array.length wasn't reactive; you had to use methods like splice.

In Vue 3, thanks to Proxy-based reactivity, these all work natively — you can add new properties to a reactive() object or set array indices/length directly and Vue will track the change correctly, with no Vue.set equivalent needed.