Vue · Junior · Question 19 of 75
Can you assign a new array to a ref holding a list?
const items = ref([]);
items.value = await fetchItems();- ✓Correct answer: Yes - replacing
.valueis tracked, and in-place mutations likepushare tracked too - 2No, refs can only hold primitives
- 3Only with
items.set(newArray)
Explanation
Vue 3's Proxy-based reactivity tracks both replacing the value and mutating arrays (push, splice, index assignment). This was a known limitation in Vue 2 that is gone now.