Skip to content

Option to set default query function for useQuery #74

Answered by cyco130
sharmapukar217 asked this question in Q&A
Discussion options

You must be logged in to vote

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?

function useDefaultQuery(key, options) {
  return useQuery(key, defaultQueryFn, options);
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sharmapukar217
Comment options

Answer selected by sharmapukar217
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants