Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a reactive reference in Vue.
Vue
const count = [1](0);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using reactive instead of ref for primitive values.
✗ Incorrect
Use ref to create a reactive reference for a primitive value like a number.
2fill in blank
mediumComplete the code to manually trigger reactivity on a ref.
Vue
import { ref, [1] } from 'vue'; const state = ref({ count: 0 }); [1](state);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using toRefs or markRaw instead of triggerRef.
✗ Incorrect
triggerRef is used to manually trigger reactivity on a ref.
3fill in blank
hardFix the error in the code to track manual reactivity correctly.
Vue
import { ref, [1] } from 'vue'; const state = ref({ count: 0 }); function increment() { [1](state); state.value.count++; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using triggerRef instead of trackRef for tracking.
✗ Incorrect
trackRef is used to track manual reactivity dependencies, which is missing here.
4fill in blank
hardFill both blanks to create a ref and manually trigger its update.
Vue
import { [1], [2] } from 'vue'; const state = [1]({ count: 0 }); function update() { state.value.count++; [2](state); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using reactive instead of ref for the object.
✗ Incorrect
Use ref to create the ref and triggerRef to manually trigger updates.
5fill in blank
hardFill all three blanks to track and trigger manual reactivity on a ref.
Vue
import { [1], [2], [3] } from 'vue'; const count = [1](0); function manualUpdate() { [2](count); count.value++; [3](count); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using reactive instead of ref for primitive values.
✗ Incorrect
Create a ref with ref, track dependencies with trackRef, and trigger updates with triggerRef.