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
Nice! Working with graphql I saw a hook called
useQuerywhich returnsloading,data,errorandrefetch.So, after some attempts to decouple the gql or rest implementation we've created a hook very similar to your
useFetchwhich returns the four variables like theuseQuery.I think that the
loadingflag could be useful for this hook too. You know, we can infer it if thedatahas a value but theloadingwill help you to know if there is a "fetching" task in progressYeah, 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.