-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Double render issue when spreading query result #8612
Comments
Tanstack Query tracks which fields of the query result you use and only rerenders when those fields change. When you spread the query result, you basically access all fields so the hook rerenders on any query state change (and there can be a lot!). You should probably return On a side note, you might not need |
Oh, I see the problem now, thank you so much. @robingullo |
Describe the bug
Update sandbox
https://codesandbox.io/p/github/hoangtrung99/react-query-reproducible/main
Hello everyone,
Today, I encountered a very perplexing error that I cannot explain. I have a fairly simple pattern. The strange thing here is that when I don't use the spread operator on the result of
useSuspenseQuery
, theCustomerListInner
component renders only once. However, when I spread the result ofuseSuspenseQuery
, myCustomerListInner
component renders twice. Even as shown in the video, merely spreading the result ofuseSuspenseQuery
causes the component to render twice, even before using that result.Your minimal, reproducible example
Sorry, I cannot create a reproducible example right now.
Steps to reproduce
Screen.Recording.2025-02-06.at.15.08.02.mov
Expected behavior
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
OS : MacOS
Browser: ARC
React Version: 19
Tanstack Query adapter
None
TanStack Query version
v5.66
TypeScript version
v5.7.2
Additional context
No response
The text was updated successfully, but these errors were encountered: