Hook to listen on cache data (e.g. useSelector) #2383
Unanswered
angelsvirkov
asked this question in
Ideas
Replies: 1 comment 1 reply
-
combined, this would yield:
usage:
⬆️
I have written about this in my blog, see: |
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.
-
Hello guys, thank you for the amazing library, it has really increased the development speed of our projects. I would like to describe one scenario we often face and then ask you if there is an existing built-in solution or that would be something that can be added to react-query in the future.
Use case
isFetching
, no automatic background refetches, etc.)Example scenario
useQuery
useQuery
at some point, maybe even very early in the lifetime of the app.useQuery
it would lead to re-rendering multiple other components at the same time because of theisFetching
and potentiallyisLoading
.performing an update on an unmounted component
. Especially if a certain parent is using the sameuseQuery
and some descendent of it is also usinguseQuery
Question
Is it possible in the current version of
react-query
to observe the query cached data with something like auseSelector
hook oruseQueryCacheData
hook which only listens on the data property of queried data (and potentially on theisLoading
anderror
)? I assume this would be possible to be implemented on top with thequeryClient.observe()
but I believe it is a very common pattern that might make sense to be part of the library.Related Resource
I have found a couple of comments which go into the direction of what I'd wish to have:
useTrackedState
with notifying on specific changes - render optimization with proxies #1554Beta Was this translation helpful? Give feedback.
All reactions