Replies: 1 comment 5 replies
-
if the client can't be a singleton for whatever reason, put it in react context and read it next to the QueryFunction. However, you have to make sure that you don't run into stale closure issues: https://twitter.com/TkDodo/status/1649786455852478465 |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am looking for a way to pass a configured client to every queryFunction, similar to how you can set up an
extraArgument
on a Redux thunk for this purpose (which is exactly what we do in the codebase I'm migrating to ReactQuery).I was expecting there to be a way to set it up on the
QueryClient
similar to:and then use it in the query function like:
I'm assuming
defaultOptions.meta
is not the right place for this, as it would get overridden for any query that is setting other metadata. The most likely answer that I am thinking of is to use aContextProvider
, but it seems unwieldy to have auseContext
hook next to everyuseQuery
hook, along with passing that into thequeryFn
.Is there another way to do this? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions