useAsync ​
Hook that provides the state of an async callback
typescript
import { useAsync } from '@siberiacancode/reactuse';
Usage ​
typescript
const { data, isLoading, isError, error } = useAsync(() => fetch('url'), [deps]);
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
callback | () => Promise<Data> | - | - The async callback |
deps? | DependencyList | - | - The dependencies of the callback |