Replies: 1 comment 5 replies
-
Hi, export defineComponent({
setup() {
const query = useQuery(['query1', myData], queryFn)
return {}
},
data: () => ({
myData: 'something'
})
) The problem here is that the setup function is invoked before the component instance is created. And you are trying to work around the problem by accessing the instance proxy, and get the data from there? If that is the case, then I think you could try to do it this way: export defineComponent({
setup() {
const myDataRef = ref()
const queryKey = reactive(['query1', myData]) // not sure if wrapping with this reactive is necessary
const query = useQuery(queryKey, queryFn)
return {
myDataRef,
}
},
data: () => ({
myData: 'something'
}),
watch: {
myData: function (val) {
this.myDataRef = val
},
}
) Please be mindful about the code, since it's written from the head and not tested in any way. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have this query
Now, 'useThis' could be some hook which gets me property classGroupId from the component this query is being used in.
So, I tried building the hook
This works but only when a change in the component triggers onUpdated. And not all changes trigger onUpdated. Let's say classGroupId is not used in template of the component, in that case change in classGroupId won't trigger onUpdated.
Please help with this.
Beta Was this translation helpful? Give feedback.
All reactions