The effect runs once initially, calling track(state, 'count') and logging 'Count is: 0'.
Step 2: State change and manual trigger
When state.count is set to 1, Vue does not update automatically because manual tracking is used. Calling trigger(state, 'count') manually runs the effect again, logging 'Count is: 1'.
Final Answer:
Count is: 0
Count is: 1 -> Option A
Quick Check:
Manual trigger causes effect rerun [OK]
Hint: Manual trigger reruns effect, so both old and new logged [OK]
Common Mistakes:
Assuming automatic update without trigger
Expecting only one log line
Confusing track with trigger
4. Identify the error in this Vue manual reactivity code snippet:
A. track is called with a property value instead of the target object and key.
B. trigger is missing after state.value update.
C. effect should not be used with manual reactivity.
D. reactive is not imported correctly.
Solution
Step 1: Check track usage
track requires two arguments: the reactive target object and the property key as a string. Here, track(state.value) passes only the value (number 10), which is incorrect.
Step 2: Correct usage of track
The correct call is track(state, 'value') to track the 'value' property on the reactive object.
Final Answer:
track is called with a property value instead of the target object and key. -> Option A
Quick Check:
track needs (object, key) [OK]
Hint: track needs object and key, not the property value [OK]
Common Mistakes:
Passing property value instead of object and key to track
Forgetting to trigger after state change
Misusing effect with manual reactivity
5. You want to optimize a Vue app by manually controlling reactivity for a large object data. Which approach correctly tracks and triggers updates only for the status property when it changes?
hard
A. Use effect(() => console.log(data.status)) without manual track or trigger.
B. Call track(data, 'status') inside the effect and call trigger(data, 'status') after updating data.status.
C. Call track(data) without property and call trigger(data) after any update.
D. Update data.status and rely on Vue's automatic reactivity without track or trigger.
Solution
Step 1: Manual tracking of specific property
To optimize, track only the 'status' property by calling track(data, 'status') inside the effect watching it.
Step 2: Trigger update after changing property
After updating data.status, call trigger(data, 'status') to notify dependents and update UI.
Final Answer:
Call track(data, 'status') inside the effect and call trigger(data, 'status') after updating data.status. -> Option B
Quick Check:
Track and trigger specific property for manual reactivity [OK]
Hint: Track and trigger only changed property for best performance [OK]
Common Mistakes:
Tracking or triggering entire object instead of property
Relying on automatic reactivity when manual control is needed
Not triggering after property update
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.