Replies: 1 comment 1 reply
-
If data gets in the cache, it's considered as accurate. If your data is "older", you can pass This will make sure |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
setQueryData
should provide an option to NOT resetisInvalidated
tofalse
.The use case is kind of common.
I have a typical application that fetches some data, and sometimes mutates the data.
Once mutation is done on the server, sometimes I want the client data to reload (invalidate), and sometimes I just update it locally, and that's it.
The problem is when I need a combination of both.
And here I start to depend on the order of calling
setQueryData
andinvalidateQueries
. Because if I firstinvalidateQueries
to designate some necessary update (including inactive queries, this is important), and then runsetQueryData
which for instance makes some kind of optimistic update, or maybe does not update anything important, but still assigns a formally new value to some old key (albeit being basically the same) - theisInvalidated
flag of that inactive query gets reset tofalse
, and no update will be happening on activation of said (eternally fresh in my setup btw) query.Currently I just work it around with the use of
getQueryState
beforesetQueryData
and theninvalidateQueries
withexact: true
afterwards to bringisInvalidated
back totrue
if necessary.But would love the ability to supply some extra option into that
setQueryData
's 3rd parameter to prohibit resettingisInvalidated
Beta Was this translation helpful? Give feedback.
All reactions