How to get RTKq interfaces ? #3615
-
First of all, I really like RTK/RTKq and I thank you for the work you do! However, there's one thing I've always had trouble with, and that's access to the various RTK interfaces. For example, I've created a "useTable" hook to make it easier to manage the tables provided by tanstack table in combination with RTKq. const { table } = useTable({
columns,
useQuery: ({ pagination }) => productApi.useReadManyProductQuery({
pagination,
sort: ['name:ASC'],
populate: ['tags']
})
}); However, I've never found a way to access the return types of a hook generated by RTKq. In the example above, I'd like to have the return type of "useReadManyProductQuery" ( useXXXQuery to be precise ) in order to properly type my "useTable" hook. Is there any way of accessing these interfaces? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
There are types exported from RTKQ's react module to help with this kind of thing, called TypedUseQueryHookResult and TypedUseMutationResult. With that said, this usage seems to break the rules of hooks? To my knowledge you shouldn't ever pass a hook directly to another hook. |
Beta Was this translation helpful? Give feedback.
There are types exported from RTKQ's react module to help with this kind of thing, called TypedUseQueryHookResult and TypedUseMutationResult.
With that said, this usage seems to break the rules of hooks? To my knowledge you shouldn't ever pass a hook directly to another hook.