You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I stumbled upon this issue while implementing RTK Query at my workplace. It seems like the return type of UseQuery hooks when extracting the type results in a type that is different from the result of the hook when invoking it.
given the above setup (hope this is understandable) ReturnType<typeof useFetchMyDataQuery>
does not result in the same type as this object receives. const data = useFetchMyDataQuery(param).
Question
What is the preferred way to define a query hook result in a interface? In my current setup the goal is to get the result of a RTK hook and pass it as a argument to another function, preferably typed.
Hello,
I stumbled upon this issue while implementing RTK Query at my workplace. It seems like the return type of UseQuery hooks when extracting the type results in a type that is different from the result of the hook when invoking it.
Example
Given a regular setup like this:
baseApi
domainSpecificApi
given the above setup (hope this is understandable)
ReturnType<typeof useFetchMyDataQuery>
does not result in the same type as this object receives.
const data = useFetchMyDataQuery(param)
.The first type results in a object with a single key
refetch
while the last object has all the fields defined in https://redux-toolkit.js.org/rtk-query/usage/queries#frequently-used-query-hook-return-valuesQuestion
What is the preferred way to define a query hook result in a interface? In my current setup the goal is to get the result of a RTK hook and pass it as a argument to another function, preferably typed.
Versions
"typescript": "4.5.4"
"@reduxjs/toolkit": "1.7.1"
tsconfig
The text was updated successfully, but these errors were encountered: