Describe the bug
<script setup lang="ts">
import { reactive } from 'vue';
import { useQuery } from '@tanstack/vue-query';
const obj = reactive<{ foo?: string }>({});
const query = useQuery({
queryKey: ['demo', () => obj.foo],
// queryKey: ['demo', () => obj.foo, obj.foo], <== no error, but redundant
queryFn: () => fetch(`/mock/getSomething/${obj.foo}`),
enable: () => !!obj.foo,
});
</script>
For codes like above, @tanstack/query/exhaustive-deps rule will throw an error:
The following dependencies are missing in your queryKey: obj.foo
Your minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-ucguwp?file=src%2FApp.vue
Steps to reproduce
pnpm run lint
- see the error
Expected behavior
Is it possible to see getter as a dep in queryKey, or we can only wrap it in computed to escape this error?
<script setup lang="ts">
import { reactive } from 'vue';
import { useQuery } from '@tanstack/vue-query';
const obj = reactive<{ foo?: string }>({});
const foo = computed(() => obj.foo);
const query = useQuery({
queryKey: ['demo', foo],
queryFn: () => fetch(`/mock/getSomething/${foo.value}`),
enable: () => !!foo.value,
});
</script>
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
Not related
Tanstack Query adapter
None
TanStack Query version
v5.57.1
TypeScript version
No response
Additional context
No response
Describe the bug
For codes like above,
@tanstack/query/exhaustive-depsrule will throw an error:The following dependencies are missing in your queryKey: obj.fooYour minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-ucguwp?file=src%2FApp.vue
Steps to reproduce
pnpm run lintExpected behavior
Is it possible to see getter as a dep in queryKey, or we can only wrap it in computed to escape this error?
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
Not related
Tanstack Query adapter
None
TanStack Query version
v5.57.1
TypeScript version
No response
Additional context
No response