Understanding Why a Directly-Passed/"Harcoded" Child-Prop Watcher Inconsistently Triggers when Parent Rerenders #8930
Unanswered
shengslogar
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Research
This seems related to #8039, which was indicated to be expected behavior, so I'm hoping for some insight into to the why my use-case behaves the way it does.
I've been directly-passing arrays and objects to Vue components for as long as I can remember, as seen in the official docs.
I always assumed that this somehow created a computed-esque property, but this only seems somewhat true. Vue 3 seems to cache static properties; Vue 2 seems to be more consistent in how it reacts.
Repro
Vue 3 demo
Vue 2 demo
I set up a few different test cases in the demos above, but the most straightforward example is as follows:
App.vue
Comp.vue
When rendered, any time you enter a different value into
<input>
with your keyboard, theprops.foo
watcher will fire. If we replaceprops.foo
with an array — say[234, 266, 273]
, exactly what's in the Vue.js documentation — the watcher will not fire.Question
Thanks in advance to anyone reading this far.
Beta Was this translation helpful? Give feedback.
All reactions