Describe the bug#
Using some state within a combine function uses the previous state value, instead of the latest one. Doing a similar approach within a select works as expected.
Your minimal, reproducible example#
https://codesandbox.io/p/devbox/elastic-noether-twswhs
Steps to reproduce#
On codesandbox link, notice how the data from query2 (using useQueries and combine), lags behind the latest value of the state used in query1 (using useQuery and select).
Expected behavior#
combine function should use the latest value of the variable in the closure
How often does this bug happen?#
Every time
Screenshots or Videos#
No response
Platform#
- OS: Windows
- Browser: Chrome
Tanstack Query adapter#
react-query
TanStack Query version#
v5.17.1
TypeScript version#
No response
Additional context#
No response
thanks for reporting. I'll look into this - or do you want to?. First "good" news is that it behaves the same in 5.0.0, so it's not a recently introduced regression.