How to invalidate/reset queries to undefined? #1720
Unanswered
blackarctic
asked this question in
Q&A
Replies: 1 comment 3 replies
-
|
resetQueries resets to the initial state. If you have |
Beta Was this translation helpful? Give feedback.
3 replies
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.
-
Hello,
I am coming from SWR where invalidating a query means resetting the data back to
undefinedwhile the data is revalidated. This is important for situations where the data is no longer acceptable until it is revalidated. In React Query this does not seem to be the case, as invalidating data keeps it in cache until the revalidation is complete. The closest solution I could find with React Query was to callqueryClient.resetQueriesinstead ofqueryClient.invalidateQueriesbut this does not reset toundefinedif using data hydration, leading to weird UI states. Am I missing something here?In case I am not missing something, I would propose adding something like a
resetToUndefined: booleanoption toqueryClient.resetQueriesthat would ignore the default value and instead reset toundefined.In addition, I would propose adding a
isManuallyInvalidated: booleanto the state of a query. This would be great for those building the UI to be able to know if data has been manually invalidated withinvalidateQueriesbut make the decision themselves on whether or not to continue to display that invalidated data.I would be happy to do this work. I would just like to discuss it first.
Beta Was this translation helpful? Give feedback.
All reactions