PersistQueryClientProvider vs Using persister as default option
What is t difference between using PersistQueryClientProvider for offline first feature for react native app vs using persister as default option for the QueryClient ? Also, we can pass persister to the individual useQuery hook to selectivily decide which query we want to store persistently but do we have reverse way arround where I can just opt out selectivly from storing in persistent storage keeping persister at global level
3 Replies
stormy-gold•16mo ago
PersistQueryClient persists the whole client (all cache entries, but you can filter) in a single item on the external storage. It will also restore everything into memory on first render.
the
persister
, when used on a query, will store each query in its own entry, and will only restore when the query is used for the fist time - thus it has a smaller memory footprint. It's basically lazily restoredflat-fuchsiaOP•16mo ago
Thank you!
@TkDodo 🔮 Could you please confirm if
persister
is only available for queries but not for mutation ? So, if we need to persist the mutation, we will have to use PersistQueryClient. Is that correct? Also, in that case is it advisable to use PersistQueryClient just for the mutation but persister
for useQuery ? One more additional question with respect to your above comment about filter, Do you mean we can selectively store the query/mutation using dehydrateOptions
option and choosing specific key ? Thanks in advance!stormy-gold•16mo ago
yes, currently only for queries
Do you mean we can selectively store the query/mutation using dehydrateOptions option and choosing specific keyyes