Replies: 1 comment 4 replies
-
Looks very good. Mind elaborating how you manually invalidate cache and refresh data? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I want to talk about persisting data on react-native app :)
Comments are welcome to do it better (and I hope this usecase can help if something around persistence is build)
My mobile app (react-native) fetch a product catalog (big JSON) containing all needed datas to display.
(It could be bad practice for some people but the purpose behind that is to provide offline content when there is no network.)
So, it load initial data saved on file system with async Expo FileSystem API (if exists) and set it to queryCache.
The corresponding query has
initialStale
and try to refetch content in background, and persist the result again.To achieve this, I use a custom hook that give me a "isLoadingCompleted" to prevent splashscreen to hide during the process (it could be anything else, if this hook fires before the query).
What I try to do is to replace Redux, Redux persist and Saga for some of my "server state".
Want to know what you think about this :
App.js
UsePersistedCatalog.js
CatalogHooks.js
Component.js
After all, that's just a POC for more "complex" needs currently hold by Redux, Redux persist (using Expo FileSystem) and Redux saga (used for other usecases out of scope).
Love these 3 libs, really, but if I can simplify some parts of my app, I'll take it :D
Beta Was this translation helpful? Give feedback.
All reactions