T
TanStack2mo ago
other-emerald

State management for animating a list of fetched items

I have a query that fetches a list of items. When the query updates and has the new list of items at myQuery.data, how can I access the previous data before this latest fetch to see which items got removed so I can still display them for a moment and add CSS to add a "removed" animation? (E.g. fade out, slide out etc.)
3 Replies
xenogeneic-maroon
xenogeneic-maroon3w ago
Not sure query supports seeing historical data fetches like mutations do. you likely just need to put your query state into a local state so you can get a diff and then once you are done animating, update your local state with the data.
loud-coral
loud-coral3w ago
<ViewTransition> – React
The library for web and native user interfaces
other-emerald
other-emeraldOP3w ago
thanks! i hope it become stable soon.

Did you find this page helpful?