Aggelos Arvanitakis
1 min readJun 8, 2020

--

Hey,

thanks for the kind words. Within the `useQuery` you need some sort of an event broadcasting mechanism in case of an error, meaning that the `useQuery` has to say "guys we have an API issue".

In the current example, this event notification system was implemented through the window location's state. In a larger scale app, you could dispatch a custom Event with the proper payload and have some other module subscribe & react to those events. This way you would solve the "coupling" issue you mentioned. In the current article, don't think about `useHistory` as a side-effect or some sort of additional functionality, but as a simple event broadcasting mechanism. We could have easily renamed it to `useErrorBroadcasting`.

--

--

Aggelos Arvanitakis