Open kuangshp opened 2 years ago
@phryneas Do you have any updates on this?
@arthedza Redux-persist is now supported by RTK-Query: https://redux-toolkit.js.org/rtk-query/usage/persistence-and-rehydration#redux-persist
With the big caveat that generally we recommend not to store api data in redux-persist: if the user presses F5 they expect to get new data, not cached data. Most of the time the RTK Query slice should just be blacklisted and not persisted at all. The internet works by fetching data from a server.
But regarding to this specific issue: that is the data that RTK Query needs. It is not meant to be beautiful to human eye. It looks like this, it will continue looking like this.
@arthedza Redux-persist is now supported by RTK-Query: https://redux-toolkit.js.org/rtk-query/usage/persistence-and-rehydration#redux-persist
With the big caveat that generally we recommend not to store api data in redux-persist: if the user presses F5 they expect to get new data, not cached data. Most of the time the RTK Query slice should just be blacklisted and not persisted at all. The internet works by fetching data from a server.
But regarding to this specific issue: that is the data that RTK Query needs. It is not meant to be beautiful to human eye. It looks like this, it will continue looking like this.
Thank you for your quick response! What about using RTK-Query + redux-persist in a react-native environment when the internet connection is poor or temporarily absent? Would this approach be acceptable or should I look for another solution?
I said generally. If you find a good reason to do it, do it. That's why we added the support.
How can one persist the the result of an rtk query api for a long time ? when page is refreshed , the fetch request goes to server to fetch the request ? How to persist with rtk query ?
@mahfuz0498 the documentation up there is not working for you? Can you provide a reproduction?
My project is using RTK-Query to request interface data, which will be stored in local storage by default, but I want the data stored in local storage to be only the data returned by the backend when I send Ajax requests, rather than including :queries, Mutations, provided and so on, and even getAccountList(undefined)。Online Demo Address