MCPcopy Index your code
hub / github.com/streamich/react-use / useAsync

Function useAsync

src/useAsync.ts:7–20  ·  view source on GitHub ↗
(
  fn: T,
  deps: DependencyList = []
)

Source from the content-addressed store, hash-verified

5export { AsyncState, AsyncFnReturn } from './useAsyncFn';
6
7export default function useAsync<T extends FunctionReturningPromise>(
8 fn: T,
9 deps: DependencyList = []
10) {
11 const [state, callback] = useAsyncFn(fn, deps, {
12 loading: true,
13 });
14
15 useEffect(() => {
16 callback();
17 }, [callback]);
18
19 return state;
20}

Callers 3

DemoFunction · 0.90
useAsyncRetryFunction · 0.85
useAsync.test.tsxFile · 0.85

Calls 1

useAsyncFnFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…