You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the documentation about the keepUnusedDataFor parameter:
Defaults to 60 (this value is in seconds). This is how long RTK Query will keep your data cached for after the last component unsubscribes. For example, if you query an endpoint, then unmount the component, then mount another component that makes the same request within the given time frame, the most recent value will be served from the cache.
I have two components, which use the useGetUsersQuery keepUnusedDataFor is set to 10 seconds
If i switch from one component (C1) to another one (C2) within 10 seconds - refetch is not happening.
If i switch from C1 to C2 and wait for more than 10 seconds, then switch to C1 - i got refetch.
Expected behaviour
Refetch will not happen even though the time frame (keepUnusedDataFor) passed, because C2 was not unsubscribed (component was not unmounted)!
Doc: This is how long RTK Query will keep your data cached for after the last component unsubscribes
This kinda ok for me anyway, but it means that the documentation is wrong. Or am i just do not understand subscribe properly?
Docs of useQuery: 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Here is the documentation about the
keepUnusedDataFor
parameter:Defaults to 60 (this value is in seconds). This is how long RTK Query will keep your data cached for after the last component unsubscribes. For example, if you query an endpoint, then unmount the component, then mount another component that makes the same request within the given time frame, the most recent value will be served from the cache.
I have two components, which use the
useGetUsersQuery
keepUnusedDataFor
is set to 10 secondsIf i switch from one component (C1) to another one (C2) within 10 seconds - refetch is not happening.
If i switch from C1 to C2 and wait for more than 10 seconds, then switch to C1 - i got refetch.
Expected behaviour
Refetch will not happen even though the time frame (keepUnusedDataFor) passed, because C2 was not unsubscribed (component was not unmounted)!
Doc: This is how long RTK Query will keep your data cached for after the last component unsubscribes
This kinda ok for me anyway, but it means that the documentation is wrong. Or am i just do not understand subscribe properly?
Docs of useQuery:
'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
Beta Was this translation helpful? Give feedback.
All reactions