0
0
Vueframework~5 mins

Watch and watchEffect in Vue - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of watch in Vue?

watch lets you run code when a specific reactive value changes. It’s like setting a listener for that value.

Click to reveal answer
intermediate
How does watchEffect differ from watch?

watchEffect automatically tracks all reactive values used inside it and reruns when any of them change, without specifying dependencies manually.

Click to reveal answer
intermediate
When should you use watch instead of watchEffect?

Use watch when you want to watch specific values and react only to their changes, especially if you want to compare old and new values.

Click to reveal answer
beginner
What is a common use case for watchEffect?

Use watchEffect for side effects that depend on multiple reactive sources without manually listing them, like updating the DOM or logging.

Click to reveal answer
intermediate
How do you stop a watcher created by watch or watchEffect?

Both return a stop function. Call this function to stop watching and clean up resources.

Click to reveal answer
What does watch in Vue require you to specify?
ANo arguments, it tracks automatically
BThe component name
COnly functions
DThe reactive value(s) to watch
Which Vue API automatically tracks dependencies inside its callback?
AwatchEffect
Bref
Ccomputed
Dwatch
What can you access in the watch callback that you cannot in watchEffect?
AThe DOM element
BThe component instance
CThe old and new values
DThe reactive source list
How do you stop a watcher in Vue?
ACall the stop function returned by <code>watch</code> or <code>watchEffect</code>
BSet the reactive value to null
CReload the component
DUse <code>unwatch</code> method
Which is best for watching multiple reactive sources without listing them?
Awatch
BwatchEffect
Ccomputed
Dref
Explain how watch and watchEffect work in Vue and when to use each.
Think about manual vs automatic dependency tracking and use cases.
You got /6 concepts.
    Describe how to stop a watcher in Vue and why you might want to do that.
    Consider cleanup and performance.
    You got /4 concepts.