useAsync
Run an async function and track its loading, error and data. Only the most recent call updates state, so a slow earlier call never overwrites a newer result.
- Level
- Intermediate
- Since
- v1.0.0
import {useAsync} from '@zenuilabs/react-hooks';Loading demo_
More in Async & Data
Async & DataIntermediateuseAsyncRetryRun an async function and retry it when it fails, with a fixed delay or backoff. Use it for flaky network calls that usually succeed on a second try.Async & DataAdvanceduseCachedFetchStale-while-revalidate data fetching with a cache shared by every component. Cached data renders instantly while a background request refreshes it.Async & DataIntermediateuseFetchFetch JSON from a URL and track data, loading and error. It aborts stale requests when the URL changes or the component unmounts, and can refetch on demand.