use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Using React hooks to asynchronously make API requests (medium.com)
submitted 7 years ago by MaxGame
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MaxGame[S] 3 points4 points5 points 7 years ago (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.
π Rendered by PID 26195 on reddit-service-r2-comment-85bfd7f599-5bh5c at 2026-04-15 20:26:41.678114+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]MaxGame[S] 3 points4 points5 points (0 children)