Option to set default query function for useQuery #74
Answered
by
cyco130
sharmapukar217
asked this question in
Q&A
-
Is there any way to pass default queryFn for useQuery ? |
Beta Was this translation helpful? Give feedback.
Answered by
cyco130
Oct 28, 2022
Replies: 1 comment 1 reply
-
No. Actually I left it out on purpose because it would force me to make the query function argument optional in TypeScript, and things will blow up in runtime if you don't give a default query function. I think it was a bad design decision in function useDefaultQuery(key, options) {
return useQuery(key, defaultQueryFn, options);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
sharmapukar217
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No. Actually I left it out on purpose because it would force me to make the query function argument optional in TypeScript, and things will blow up in runtime if you don't give a default query function. I think it was a bad design decision in
react-query
too. May I suggest you use a wrapper hook like the following?