Skip to content
Discussion options

You must be logged in to vote

in your example, useGetData is exactly the same as useQuery, so I don't see any advantages to this approach:

const { status, data, error, isFetching } = useGetData( KEY, queryFn );
const { status, data, error, isFetching } = useQuery( KEY, queryFn );

if you want to create low level abstractions, you have to deal with lots of generics (useQuery takes 4 generics). You can read more about them in my blog: https://tkdodo.eu/blog/react-query-and-type-script#the-four-generics

I also have a twitter thread on the topic if you really want to do something generically in your low-level wrapper: https://twitter.com/TkDodo/status/1491451513264574501

Replies: 1 comment 1 reply

Comment options

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

Answer selected by ankursehdev
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