Tanstack-query: expo application when we close/kill the app the store should be cleared?
I'm working on a react-native application and one of the issues that we have is for example this hook:
getExample will cache the response for 2 minutes (staleTime: 2 * 60 * 1000). If another system updates the /example data during that window, TanStack Query won’t auto-notice unless a refetch is triggered (mount/focus/reconnect/explicit refetch), which is expected.
Question: If we kill or close the app before those 2 minutes expire, will the next launch refetch from the endpoint, or will we still see cached store values?
Context: I’d like to confirm whether the in-memory store is cleared on app close. I’m considering:
I didn’t find much documentation confirming this in React Native.
2 Replies
correct-apricot•2mo ago
Question: If we kill or close the app before those 2 minutes expire, will the next launch refetch from the endpoint, or will we still see cached store values? Context: I’d like to confirm whether the in-memory store is cleared on app close. I’m considering:Because you are using default in memory store, then it depends on how android/iOS manages memory. Like, "does android/iOS clears memory if the application is closed or killed" kind of stuff.
absent-sapphireOP•2mo ago
and there's a way to use something else ? or how I should take more control about those stuff?
I mean, instead of just relegate to refresh always I can just refresh if the app is killed
Could you point me to any documentation or resources where I can read more about that?