Skip to content

Some questions about watchEffect() #10563

Discussion options

You must be logged in to vote

a ref is deeply reactive, but it does not pre-emptively traverse the whole tree of properties recursively. properties are tracked when accessed, and those that are not accessed, are not tracked.

But when you set deep: true on a watch(someRef), then Vue will recursively walk the whole object on initialization of the watcher, and it's nested children objects / arrays etc, and track every single property. That can potentially created thousands upon thousands of dependencies that now need to be tracked, if you have a large enough complex object/array tree.

That in turn will can add to the memory footprint - and it can make the watch callback run even though the callback might not even be inte…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@xuanzhi33
Comment options

@LinusBorg
Comment options

@xuanzhi33
Comment options

@LinusBorg
Comment options

Answer selected by xuanzhi33
@xuanzhi33
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants