vuejs / composition-api

Composition API plugin for Vue 2
https://composition-api.vuejs.org/
MIT License
4.19k stars 343 forks source link

reactive([]) does not trigger computed #904

Closed bkuster closed 2 years ago

bkuster commented 2 years ago

Issue

When creating a reactive array and using it in a computed, changes to the array (using push etc.) does not trigger the computed property as expected.

See this code pen for a working example of this in Vue3.

{
  setup() {
    const foo = reactive([]);
    const bar = computed(() => foo.map(f => f));
    setTimeout(() => { foo.push(true); } , 1000);

    return {
      bar,
    };
  },
}
FrontDev commented 2 years ago

Use ref for []

composition-api/issues/219

bkuster commented 2 years ago

okay, so this is a known limitation and i have simply missread the documentation, assuming, if i have a reactive array, i will need refs within said array. sorry for the noise.