Replies: 1 comment 1 reply
-
It’s nota query then. Put it into a global state manager like Sorry but if it doesn’t have a
I plan to make this error in TypeScript, too, so please don’t rely on this pattern. |
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
-
I have a use case.
User can log into the app, by calling a mutation. After that we put the user account information under certain key in queryCache. That information could be also actively updated if user chooses to change their profile info etc, different reasons and scenarios.
That's on one hand.
On the other hand, we need to consume the currently logged in user from multiple places within the app. Consume, but never request. Means, if there's no data under the key, we should just get
undefined
, and never run anyqueryFn
. At the same time, once user data is ever updated in a few specific places I mentioned earlier, all the consumers must receive the update. User name (or balance) was changed? Fine, rerender the components showing the user name (or balance) everywhere automatically.To achieve this behavior on the side of consumption I used to use a
useReadonlyQuery
wrapper that internally runs something likeIt worked just fine, but after updating to the latest version of
react-query
I started to receive errorFor now, I solved it by providing a stopgap
queryFn: () => undefined
.But that left me wondering if this use case is already supported by the lib directly, but I just somehow missed it?
Beta Was this translation helpful? Give feedback.
All reactions