Return function to run useQuery? #1897
Unanswered
JamesBrightman
asked this question in
Q&A
Replies: 2 comments 2 replies
-
best way is probably:
this will enable the query on calling the function the first time. react-query is declarative, not imperative, so if you really want to run a query only when some action is taken, you can keep it disabled at all times and run it with the returned |
Beta Was this translation helpful? Give feedback.
2 replies
-
I think also as @JamesBrightman that it makes sense to return the query function as it is done in the useMutation hook with the |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
The useMutation query has a function you can call to actually run the mutation. I use this to create myself a custom hook, eg/
Calling
postFile
runs the mutation.My question is, is there a way to do this with
useQuery
? There doesn't seem to be any return function to actually run the query, eg/const [getX, {isLoading, error, data}] = useQuery(x,y);
- this is invalid but is the behaviour I would like.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions