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•3w 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•3w ago
ViewTransitions can solve this: https://react.dev/reference/react/ViewTransition#animating-an-element-on-enter
<ViewTransition> – React
The library for web and native user interfaces
other-emeraldOP•3w ago
thanks! i hope it become stable soon.