-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
combine
stable reference is not called with correct parameters
#8781
Comments
Isn't this a natural behavior caused by the function reference value not changing?
Looking at the “if” statement in the link, it looks like the intended behavior. Wouldn't it probably go something like this? (I used a translator)
|
Hey @joseph0926 , thank you for your answer! First, I believe that the behavior when passing a stable reference and when not passing a stable reference should be the same. That alone is already an issue to me. Second, the result of useQuery should reflect the queries passed to useQuery. If I change the queries, it should reflect this in the results. So basically step 6 is not correct to me. Similarly, right now, when I change the key of a query, it immediately sets back |
@lcswillems |
This is merely a performance optimization. When the reference is stable, you can’t close over values, so there’s no need to re-run combine on a render if For inline functions, that’s not the case. It’s really the same as we do with However, it can of course be that we got something wrong in this caching. I don’t have the time right now to look into it. A PR with a failing test case would already be very helpful. |
Describe the bug
Clicking a few times the "Increase" button would give those logs:
Which is not the correct behavior.
When I'm not using a stable reference, i.e. directly passing
combine
:I get those logs:
Which is the correct behavior.
Your minimal, reproducible example
https://codesandbox.io/p/devbox/dank-smoke-7h8ssj?file=%2Fsrc%2Findex.tsx
Steps to reproduce
Open the repro. Click on "Increase". Look at the logs.
Expected behavior
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
Linux
Chrome
Tanstack Query adapter
react-query
TanStack Query version
5.59.20
TypeScript version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: