-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Unexpected re-rendering components when update state #7852
Comments
interesting. seems to be related to I think what happens is that with We cannot "take over" the element from the next position because we don't know how they relate. You won't see the problem with react state and lists, because react keeps track of elements with a special You can:
|
Thank you for the work around idea, can you check the permission access of your codesanbox link ? |
sorry about that. updated it 👍 |
Describe the bug
When removing or adding an item of list, by queryClient.setQueryData, then some other items' components are also re-rendered. I make sure that components are wrapped with React.memo. If remove the 1st item, then 2nd,3rd,... will be re-rendered. If remove the 3rd item, then 4th,5th will be re-rendered
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/memo-testing-react-query-kclcgq
Steps to reproduce
Expected behavior
As a user, I expect when changing (delete, add,...) an item in list with queryClient.setQueryData, other items' components will not be re-rendered
Screenshots or Videos
Tanstack Query adapter
react-query
TanStack Query version
5.51.21
TypeScript version
5.5.4
The text was updated successfully, but these errors were encountered: