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
useQuery
which returnsloading
,data
,error
andrefetch
.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 theuseQuery
.I think that the
loading
flag could be useful for this hook too. You know, we can infer it if thedata
has a value but theloading
will 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.