Skip to content

Unexpected reactivity in shallowReactive array #9900

Discussion options

You must be logged in to vote

shallowReactive definitely is a reactive object as well.

Just because you create shallow reactives doesn't mean there is no reactive state deeper in them. For example I always use shallow reactivity by default, because it's faster and it leads to less unwanted surprises. Yet I sometimes put reactive objects inside a shallow reactive array.

Anyway, for your case I looked at the source code.
The relevant code is https://github.com/vuejs/core/blob/main/packages/runtime-core/src/apiWatch.ts#L213
Clearly deep observation is not "the default" for a reactive object: it's forced.

I personally think this is an unfortunate limitation, it'd be useful to be able to override that default with { deep: …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jods4
Comment options

Answer selected by ragnarlotus
Comment options

You must be logged in to vote
1 reply
@jods4
Comment options

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