paint-brush
Creating a Custom Hook for Fetching Asynchronus Data: useAsync Hook with Cacheby@devsmitra
3,845 reads
3,845 reads

Creating a Custom Hook for Fetching Asynchronus Data: useAsync Hook with Cache

by Rahul Sharma7mNovember 17th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

We can create a custom hook that will be used to handle all asynchronous data fetching and updating the state updating. Data fetching logic is the same logic that is used to fetch data and update the state. We are showing a loading indicator to show the user that the app is loading data, and hiding the content until the data is ready. The third thing is that we are setting the data to the state that we got back from the API. We can also create a flexible component that is more flexible than the traditional component lifecycle.

Company Mentioned

Mention Thumbnail
featured image - Creating a Custom Hook for Fetching Asynchronus Data: useAsync Hook with Cache
Rahul Sharma HackerNoon profile picture
Rahul Sharma

Rahul Sharma

@devsmitra

I'm a technology enthusiast who does web development.

L O A D I N G
. . . comments & more!

About Author

Rahul Sharma HackerNoon profile picture
Rahul Sharma@devsmitra
I'm a technology enthusiast who does web development.

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite