T
TanStack5mo ago
eastern-cyan

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
conscious-sapphire
conscious-sapphire4mo 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.
stormy-gold
stormy-gold4mo ago
<ViewTransition> – React
The library for web and native user interfaces
eastern-cyan
eastern-cyanOP4mo ago
thanks! i hope it become stable soon.

Did you find this page helpful?