RFC: Component-level Visibility-based Query Management #9934
Replies: 2 comments
-
|
correct me if I’m wrong but I don’t think this has a lot to do with react-query - it’s more about visibility management and then one consumer of that would be refetching with react-query? Probably a better design for this lib would be to just expose a function that will be called whenever something becomes visible, and then users can do with that information what they want instead of having query specific options like, invalidateOnFocus, refetchOnFocus, resetOnFocus etc. I don’t think this has a place in the query repo but it sounds like a nice package you could publish. |
Beta Was this translation helpful? Give feedback.
-
|
@TkDodo Thanks for the feedback. Visibility management is a concern, but not the only one. One thing I'm thinking about though: in setups where modules have separate QueryClient instances, each module usually has its own QueryClientProvider. If we only expose an What do you think? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
RFC: Component-level Visibility-based Query Management
Implementation
Here
Problem
refetchOnWindowFocusworks well, but it's window-scoped.In practice, I often need finer control:
Doing this manually means setting up IntersectionObserver, tracking state, coordinating invalidation... it adds up.
Proposal
Visibility-based query management at the component level.
Hook
Component
How it works
Use cases
Third-party Widget Integration
Isolated Feature Modules
MFE Portal
On window focus, only visible sections refetch — each with their own QueryClient.
Open questions
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions