React best practices are a bit out of scope for this channel, but in general, I don't think it's good practice to have API fetch code directly in the hook. I suspect the reason the example in the react code has the fetch directly in the hook is just so all the context is there (and API layering is out of scope for the example).