Great article! Just wondering about the `useQuery` implementation where you use the `useHistory` inside it. I feel like the useHistory shouldn't be part of the `useQuery` all in all. The reason I have for that is because it is not related to the query mechanism or network layer. I think `useHistory` is part of the implementation or on the consumer part already. I think it's gives `useQuery` another responsibility which is to redirect in case of error. And having that responsibility, will add extra state. And adding/maintaining extra state will soon be tedious. But, want to hear your opinion. I'm still learning and want to see get new insights and thoughts 😄

Probably if I would to handle error during network calls would be something like this:


const {




} = useQuery('enter_url');


error = will be derived from the `catch` block. And just passing it to the consumer and let the consumer decides what to do with it.


Improvise, Adapt, Overcome

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store