persistQueryClient support suspense?
I'm using react-query in react-native, and I'm trying to use persistQueryClient to cache it locally, but suspense doesn't seem to work in my app and the data comes down as undefined.
2 Replies
rare-sapphireOP•3y ago
here is my queryClient Options
rare-sapphireOP•3y ago
is there any potential issues when using persistQueryClient outside of react lifecycle?
// outside of lifecycle
persistQueryClient({
queryClient,
persister: localStoragePersister,
})
// inside of lifecycle
function App() {
return (
<PersistQueryClientProvider>
...
</PersistQueryClientProvider>
)
}
in the docs, the former has comments below. but i’m not sure there’s any problem when do not unsubscribe from syncing.
https://tanstack.com/query/v4/docs/react/plugins/persistQueryClient#usage-with-react
// 🚨 never unsubscribes from syncing
persistQueryClient | TanStack Query Docs
This is set of utilities for interacting with "persisters" which save your queryClient for later use. Different persisters can be used to store your client and cache to many different storage layers.
Build Persisters