0
0
Vueframework~20 mins

Trigger and track for manual reactivity in Vue - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of Manual Reactivity
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding manual reactivity triggers in Vue

In Vue 3, when using signal for manual reactivity, which method is used to notify Vue that a signal's value has changed and should update the UI?

Asignal.notify()
Bsignal.trigger()
Csignal.value = newValue
Dsignal.track()
Attempts:
2 left
💡 Hint

Think about the method that explicitly tells Vue to update when the value changes.

query_result
intermediate
2:00remaining
Result of tracking a signal in Vue

Given the following Vue code snippet, what is the output of console.log(count.value) after increment() is called?

import { signal, effect } from '@vue/reactivity';
const count = signal(0);
function increment() {
  count.value++;
  count.trigger();
}
effect(() => {
  console.log('Count is:', count.value);
});
increment();
ANo output
BCount is: undefined
CCount is: 0
DCount is: 1
Attempts:
2 left
💡 Hint

Consider how the signal value changes and triggers effects.

📝 Syntax
advanced
2:00remaining
Identify the syntax error in manual signal tracking

Which option contains a syntax error when trying to manually track a signal's dependencies in Vue?

import { signal } from '@vue/reactivity';
const state = signal(5);
function read() {
  track(state);
  return state.value;
}
AUsing <code>track(state)</code> inside the function
BDefining <code>state</code> as a signal with initial value 5
CAccessing <code>state.value</code> to read the signal
DImporting <code>track</code> from '@vue/reactivity'
Attempts:
2 left
💡 Hint

Check if track is a valid function to call directly.

optimization
advanced
2:00remaining
Optimizing manual reactivity with signals

You want to optimize a Vue component that uses a signal to track a large list. Which approach best reduces unnecessary updates?

ACall <code>listSignal.trigger()</code> after every item change
BAvoid using signals and use plain arrays instead
CUse a computed signal that depends on filtered items and trigger only when filters change
DReplace the entire list with a new array and call <code>trigger()</code>
Attempts:
2 left
💡 Hint

Think about minimizing updates by tracking only relevant changes.

🔧 Debug
expert
3:00remaining
Debugging missing UI updates with manual triggers

In this Vue code, the UI does not update after changing count.value. What is the cause?

import { signal, effect } from '@vue/reactivity';
const count = signal(0);
function increment() {
  count.value++;
  // missing trigger call here
}
// effect to log count
effect(() => {
  console.log('Count:', count.value);
});
increment();
AThe <code>increment</code> function does not call <code>count.trigger()</code>
BThe signal was not created properly
CThe effect is not defined correctly
DThe signal value cannot be incremented directly
Attempts:
2 left
💡 Hint

Check what is needed to notify Vue about changes in manual reactivity.