import { DependencyList , useEffect } from 'react' ; import type { FunctionReturningPromise } from '../types' ; import { useAsyncFn } from './useAsyncFn' ; export function useAsync < T extends FunctionReturningPromise > ( fn , deps = [ ] ) { const [ state , callback ] = useAsyncFn ( fn , deps , { loading : true } ) ; useEffect ( ( ) => { callback ( ) ; } , [ callback ] ) ; return state ; }