-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Describe the bug
It appears that after hydrating from local storage, the cacheTime gets reset back to the default of 5 minutes.
I use 1000 * 60 * 60 * 24 which is 86400000 ms (24 hours). You can see in my GIF that this is correctly set at first, but as soon as I refresh the page and it hydrates from local storage, the cacheTime is set back to the default of 300000 ms (5 minutes).
It will then garbage collect the queries after 5 minutes if you navigate away from the app, which removes them from local storage, rendering local storage pretty useless...
To Reproduce
https://codesandbox.io/s/react-query-persist-bug-4k32q
- Click on some buttons to save some queries
- Observe in devtools that the
cacheTimeis correct (86400000) - Refresh the page
- Observe that the
cacheTimeis now 300000 - Navigate away from the codesandbox for 5 minutes and come back to it
- Observe that there are no longer any queries saved in local storage
Expected behavior
Uses the correct cacheTime so queries are not forced out of local storage early.
Desktop (please complete the following information):
- OS: macOS
- Browser: Chrome
- Version: 3.5.6
Additional context
Add any other context about the problem here.
