T
TanStack2y ago
extended-salmon

Optimistic updates without re-rendering everything?

Hi, I have a shopping cart. When a user changes the quantity of some item, I'd like to do an optimistic update along with the mutation. If I call:
queryClient.setQueryData(['cart'], /* shopping cart where relevant item is modified */);
queryClient.setQueryData(['cart'], /* shopping cart where relevant item is modified */);
All shopping cart items are re-rendered, each component is created from scratch, scroll position is lost. Is there any way to do the update a single property of one item without re-rendering everything? SolidJS has a SetStore API function for fine-grained updates (see docs - tutorial and api reference). Does TanStack Query expose this function?
2 Replies
stormy-gold
stormy-gold2y ago
Can you open an issue for this with a little repro? I believe the solid-query adapter already mutates the resource, which should perform a reconcile and hence have a fine-grained update.
extended-salmon
extended-salmonOP2y ago
Unfortunately, reconcile is disabled by default. https://github.com/TanStack/query/issues/7001
GitHub
Solid Query causes unnecessary rerender on every fetch when working...
Describe the bug I use Solid Query to load a list of objects. Every time Solid Query runs the query and gets a new result, everything is rendered, even if the result has not changed. It causes form...

Did you find this page helpful?