Deep Watcher in Vue

Published on: Monday, 19.02.2024

When watch() is called directly on a reactive object it automatically tracks the mutations of its nested properties.

However, that is not the case when a getter returns a reactive object. The watcher than fires only if the getter returns a different object. We can change this by adding the deep option in the watcher.

watch(stateToWatch, () => { // Your logic goes here }, { deep: true } )

Note: Can affect performance when used on large data structures.