T
TanStack3mo ago
optimistic-gold

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
genetic-orange
genetic-orange3mo 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.
complex-teal
complex-teal3mo ago
<ViewTransition> – React
The library for web and native user interfaces
optimistic-gold
optimistic-goldOP3mo ago
thanks! i hope it become stable soon.

Did you find this page helpful?