Vue · Senior · Question 5 of 75

What is effectScope for?

const scope = effectScope();
scope.run(() => {
  const doubled = computed(() => counter.value * 2);
  watch(doubled, log);
});
scope.stop();

Explanation

Components create a scope automatically. Manual scopes are used in libraries and shared composables (e.g. a singleton store created outside components) to avoid leaking effects.

Further reading

Problem with a question

Vue · Senior · question 5

Test yourself

Take the Vue · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz