Closed
Description
Describe the bug
This seems like essentially the same problem as #5910, except with invalidateQueries
instead of refetch
. It also happens with resetQueries
(maybe more?). Basically, the query key that's passed into the query function can be out of sync with the current value of the ref after the ref is changed.
Your minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-dnf3kd?file=src%2FApp.vue
Steps to reproduce
- Open up the reproduction
- Look at the console logs, which print:
foo foo
foo bar
bar bar
Notice that in in the second line, queryKey[1]
and foo.value
are out of sync. There's also an extra fetch due to this.
Expected behavior
I would have expected it to print:
foo foo
bar bar
where the query key is in sync with the ref and there's no redundant fetch.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: Windows 10
- Browser: Chrome
- Version: 119
Tanstack Query adapter
vue-query
TanStack Query version
v5.8.4
TypeScript version
No response
Additional context
No response