queryClient.getQueryData is undefined once refresh
Is there a way that it will fetch the data once refresh?
1. Fetch list of data in index page
2. Go to create new page
3. Refresh the create new page
4. getQueryData is now undefined
3 Replies
xenial-black•4y ago
What do you mean with "refresh" ? Like: reload the browser?
rival-blackOP•4y ago
yesss
xenial-black•4y ago
the cache lives in memory. if you reload the page, it's gone. if you want that, you need to persist the cache somewhere else, e.g. localstorage. have a look at the persisters: https://tanstack.com/query/v4/docs/plugins/persistQueryClient
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