Hey Matthias, thanks and good question! I’d recommend having another custom hook to wrap the client that interacts with your remote API. So for example if you were interacting with the Spotify API, then you would have another hook called useSpotifyApi which would in turn consume useSpotifyStore. But going back to the Todos example, a solution might look like this.

Here’s a working example: https://codesandbox.io/s/todos-async-useapi-qpf2o

Software Engineer at Target. I’m more active on twitter https://twitter.com/MalerbaAustin.

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