T
TanStack3y ago
foreign-sapphire

Persister Timing

Hey! I noticed that theres about a 1 second delay between the state updating on the screen and the write being called to the persister. Any way to configure that to be faster? On logout I call queryClient.clear() and if the user happens to refresh the page fast enough, their auth cookie gets unset but the cache still holds the user information. Unlikely a user will see this, but just curious if I can do anything to fix it
2 Replies
national-gold
national-gold3y ago
that's the default throttleTime time, you can customize that: https://tanstack.com/query/v4/docs/react/plugins/createSyncStoragePersister#options
createSyncStoragePersister | TanStack Query Docs
Installation This utility comes as a separate package and is available under the '@tanstack/query-sync-storage-persister' import.
foreign-sapphire
foreign-sapphireOP3y ago
Damn, sorry, IDK how I missed that 🤦‍♂️ Will probably set it to 0 because the storage library I use has its own throttling logic Thanks!

Did you find this page helpful?