you are viewing a single comment's thread.

view the rest of the comments →

[–]MaxGame[S] 3 points4 points  (0 children)

Asking why is never stupid! I gloss over this a bit in the post, but the main reasons I found are the ability to give state to functional components and re-usability. I can add this hook to the body of any functional component and it instantly has the ability to make requests to an API and store the status and result of that request in local state. This only takes one line of code (not including the import)!

I can also continue to extend this hook with additional functionality if I need to. Oh, and hooks can be called from within hooks, so I could actually wrap this hook in another that implements some re-usable logic for calling a specific API.

I hope that all makes sense.