DEV Community

Discussion on: Custom React useFetch() hook for data fetching with revalidation

Collapse
chema profile image
José María CL

Nice! Working with graphql I saw a hook called useQuery which returns loading, data, error and refetch.

So, after some attempts to decouple the gql or rest implementation we've created a hook very similar to your useFetch which returns the four variables like the useQuery.

I think that the loading flag could be useful for this hook too. You know, we can infer it if the data has a value but the loading will help you to know if there is a "fetching" task in progress

Collapse
damiisdandy profile image
damilola jerugba Author

Yeah, I kept thinking whether I should add a loading value or not, I initially did but I removed it, You can contribute to the repo.