Vue · Middle · Question 56 of 75
How do you stop a watcher before the component unmounts?
const stop = watch(source, callback)
// later
stop()- ✓Correct answer: Call the handle returned by
watch/watchEffect - 2Set the source to
null - 3Watchers can't be stopped manually
Explanation
Watchers created synchronously in setup stop automatically on unmount. Watchers created asynchronously must be stopped manually to avoid leaks.