Type for query with 0 parameters #1548
Answered
by
markerikson
ChuckJonas
asked this question in
Q&A
-
I'm trying to figure out how to define a query that has no parameters. I can do something like this: getPosts: builder.query<WorkItem[], void>({ ... }) and I can then call However, I cannot pass the second parameter for options if I do this: useGetPostsQuery({refetchOnFocus: true})
//Argument of type '{ refetchOnFocus: boolean; }' is not assignable to parameter of type 'void | unique symbol'.
Type '{ refetchOnFocus: boolean; }' is not assignable to type 'unique symbol Is there a proper way to define a query with any params? |
Beta Was this translation helpful? Give feedback.
Answered by
markerikson
Sep 24, 2021
Replies: 1 comment
-
You always have to pass a "query cache key" as the first arg to a |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ChuckJonas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You always have to pass a "query cache key" as the first arg to a
useQuery()
hook. In this case, the correct cache key would beundefined
. So:useGetPostsQuery(undefined, {refetchOnFocus: true})
.