Reputation: 723
I am new to react-query
and appreciate the way it caches the api response
. I am just curious , is there an out-of-the-box way to cache a formatted version (more suitable to frontend) of api response
than the response itself?
We use to do that in react-redux
where we can cache something in store
in a specific format so that interested react components can read that formatted value.
Any clues?
Upvotes: 0
Views: 843
Reputation: 28938
you can return whatever promise you want from the queryFn
- it doesn't have to be the exact api response. Transformations can be done, too.
I've done an extensive write-up on this topic: https://tkdodo.eu/blog/react-query-data-transformations
Upvotes: 1