Skip to content

Problem with understanding of documentation regarding reactive object and watchEffect (featuring playground) #7375

Discussion options

You must be logged in to vote

This behavior is because the Reactivity Object's properties are not accessed, so no dependencies are collected. Modifying the value does not trigger the watchEffect.

So you can use console.log("watchEffect", reactiveObject.test); to collecte the dependency.

Or you can use watch

watch(source, () => {
	// ...
}, { deep: true })

When directly watching a reactive object, the watcher is automatically in deep mode:

const state = reactive({ count: 0 })
watch(state, () => {
  /* triggers on deep mutation to state */
})

https://vuejs.org/api/reactivity-core.html#watch

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cndev123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants