Skip to content

useAsync ​

utilities
test coverage
Last changed: last month

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

NameTypeDefaultNote
callback() => Promise<Data>-- The async callback
depsDependencyList-- The dependencies of the callback

Source ​

Source • Demo

Contributors ​

Avatardebabin
Avatarbabin

Released under the MIT License.