Problem with reactivity understanding #11383
Unanswered
biwchi
asked this question in
Help/Questions
Replies: 1 comment
-
const fields = computed(() => {
if (!data.value) {
update()
return []
}
return data.value
}) See the playground. Hope it will help you. If you have any more questions, you can edit the code in playground and share the url here. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a problem with the Vue reactivity system. Below you can see a store that contains a ref called
data
with the data structureRecord<string, Array<SomeItems>>
.My goal is that when a component uses a key from
data
, it should fetch the data if the value isnull
and return an empty array. Later, when the data is received, it should be assigned todata[key]
.I use
computedWithControl
from VueUse. Whendata
changes, the computed properties that depend onfields
should be triggered to recompute. However, not only does this not work properly, but it also breaks some other computed properties in this computed chain.The problem is that when some key of the "data" ref is changed, it doesn't trigger the recomputation of all computed properties that depend on it.
I tried lots of things such as creating
customRef
and manually triggering updates when I change thedata
state, but I didn't achieve the expected result.Anyone who can help me or explain what I am doing wrong, I would be very grateful.🙏
Beta Was this translation helpful? Give feedback.
All reactions