Consider this Vue 3 code using shallowReactive:
const state = shallowReactive({ user: { name: 'Alice', age: 30 } })
state.user.name = 'Bob'What will Vue track and update reactively?
Think about what shallow means in this context.
shallowReactive makes only the top-level properties reactive. Nested objects inside are not converted to reactive proxies, so changes inside them are not tracked.
Given this Vue 3 code:
const user = shallowRef({ name: 'Alice', age: 30 })
user.value.name = 'Bob'
console.log(user.value.name)What will be logged?
Consider how shallowRef treats the wrapped object and its nested properties.
shallowRef wraps the object shallowly, so the reference itself is reactive but nested properties are not. However, you can still mutate nested properties directly, and the change will be visible when accessing user.value.name.
Choose the correct Vue 3 code snippet that creates a shallow reactive object with a nested array, so only the top-level object is reactive but the array is not deeply reactive.
Remember that shallowReactive only makes the top-level reactive.
Option C uses shallowReactive on the top-level object, so items array is not deeply reactive. Other options either deeply reactive or mix shallowRef/reactive incorrectly.
Look at this Vue 3 code:
const state = shallowRef({ count: 0, nested: { value: 10 } })
function increment() {
state.value.nested.value++
}Why might Vue not update the UI when increment() is called?
Think about what triggers Vue's reactivity system for refs.
shallowRef tracks changes only when the reference itself changes. Mutating nested properties does not trigger updates because Vue does not track deep changes inside shallow refs.
Choose the most accurate description of how shallowRef and shallowReactive differ in Vue 3 reactivity.
Focus on what each function returns and how deep their reactivity goes.
shallowRef returns a reactive reference object whose value is not deeply reactive. shallowReactive returns a reactive proxy object that tracks only top-level properties, ignoring nested ones.