Replies: 1 comment
-
The issue you have here is from accessing const { farm_id } = toRefs(props);
useQuery({
queryKey: ['/report/list', farm_id],
queryFn: async ({ queryKey: [endpoint, farmId] } = {}) => {
await $api.value.get(endpoint, { params: { farm_id: farmId } })
}
}) or const farm_id = computed(() => props.farm_id );
useQuery({
queryKey: ['/report/list', farm_id],
queryFn: async ({ queryKey: [endpoint, farmId] } = {}) => {
await $api.value.get(endpoint, { params: { farm_id: farmId } })
}
}) |
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.
-
My component is a dynamic component inside , for producing reports for various farms. There are other similar components, hence dynamic component, but this one takes farm Id as prop and produces report from data read from server. Inside
setup
function, I have useQuery which has query key ['report', props.farmId]. Now, since it is insideKeepAlive
, setup runs only once and useQuery does not react on props change.Simplified code would be:
How to make this useQuery reactive, so it switches to different query when farm Id changes?
Beta Was this translation helpful? Give feedback.
All reactions