0
0
Vueframework~5 mins

Reactivity caveats and limitations in Vue - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What happens if you add a new property to a reactive object after it is created in Vue 3?
New properties added to reactive objects are tracked and reactive in Vue 3, unlike Vue 2 where you had to use Vue.set. However, if you add properties to a plain object that is not reactive, Vue won't track them.
Click to reveal answer
intermediate
In Vue 3, what happens if you modify an array by setting an index directly (e.g., arr[1] = value)?
It triggers reactivity because Vue's Proxy system detects array index changes. This was a limitation in Vue 2 where splice or other methods were needed.
Click to reveal answer
intermediate
Explain why Vue's reactivity system might not detect changes to properties inside a Map or Set.
Vue's reactivity system does not automatically track changes inside Map or Set because they are complex data structures. You need to use Vue's reactive APIs or wrap them properly to track mutations.
Click to reveal answer
beginner
What is a common pitfall when using reactive refs with objects in Vue 3?
A common pitfall is forgetting to unwrap refs inside templates or scripts, leading to unexpected behavior. Use .value to access or modify the inner value of a ref.
Click to reveal answer
advanced
Why might deep nested changes in reactive objects sometimes not trigger updates in Vue?
If nested objects are not reactive or created outside Vue's reactive system, changes inside them won't trigger updates. Always create nested objects using reactive or ref to ensure deep reactivity.
Click to reveal answer
In Vue 3, how do you ensure adding a new property to an object is reactive?
AUse Object.assign to add the property
BUse Vue.set method
CAdd the property directly to the reactive object
DRecreate the entire object with the new property
Which method should you use to update an array element reactively in Vue?
AUse arr.splice(index, 1, value)
BDirectly assign with arr[index] = value
CUse arr.push(value)
DUse Object.assign(arr, {index: value})
What must you do to track changes inside a Map in Vue's reactivity system?
ANothing, Vue tracks Map changes automatically
BWrap the Map with reactive() or ref()
CConvert Map to a plain object
DUse Vue.set on Map keys
How do you access the value inside a ref in Vue 3 scripts?
Aref.get()
Bref()
Cref.inner
Dref.value
Why might changes in deeply nested objects not trigger updates in Vue?
ABecause nested objects are not reactive if created outside Vue's reactive system
BBecause Vue only tracks shallow changes
CBecause Vue does not support nested objects
DBecause nested objects must be arrays
Describe common limitations of Vue's reactivity system and how to work around them.
Think about what Vue can and cannot detect automatically and how to ensure reactivity.
You got /5 concepts.
    Explain how direct assignment to array indexes is handled in Vue 3 reactivity and best practices.
    Consider how Vue watches array changes.
    You got /4 concepts.