keepUnusedDataFor vs refetchOnMountOrArgChange #1484
-
I've already read RTK Query documentation but there's something I still don't understand quite well. Considering equal cache validation times for both props, what is the practical difference between |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
keepUnusedDataFor
: Imagine you unmount your last component usinguseMyQuery(5)
. AfterkeepUnusedDataFor
seconds, the cache value will now be deleted from cache.refetchOnMountOrArgChange
: Imagine you already have a component usinguseMyQuery(5)
. Now a new component mounts and also usesuseMyQuery(5)
. Normally, that data would not refetch. IfrefetchOnMountOrArgChange
is set and more time than that value has passed when that new component mounts, it will re-fetch even though a result is already in the cache.