-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
docs: clarify default behavior of invalidateQueries refetching #9541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: clarify default behavior of invalidateQueries refetching #9541
Conversation
...ching Update documentation to explain that by default invalidateQueries only refetches active queries, while inactive queries are marked stale but not immediately refetched. Add guidance on using type/refetchType 'all' option to refetch all queries (active + inactive) to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is pretty much the same as the two points above are also saying. The second one only says "is currently being rendered via useQuery
or related hooks", maybe this could be re-worded to "active queries", and then explained what an active query is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is partially wrong. setting type: 'all'
wouldn't achieve that. It's also the default behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t understand that sentence - what is "all clients or views" referring to? Imo there’s really no need to set refetchType: 'all'
, as it will likely lead to overfetching. It's something we have documented in the API docs, but I don’t think we need to emphasize on this with a guide.
View your CI Pipeline Execution ↗ for commit 4ee626c
☁️ Nx Cloud last updated this comment at |
This PR updates the documentation for the invalidateQueries method in React Query to clarify the default behavior of query invalidation and refetching.
-It explains that by default, only active queries are immediately refetched.
-Inactive queries are marked stale but not automatically refetched until they become active again.
-It adds instructions on how to force invalidation and refetching of all queries (both active and inactive) by using the type: 'all' or refetchType: 'all' option.
closes #9531