# `useAsync` React hook that resolves an `async` function or a function that returns a promise; ## Usage ```jsx import {useAsync} from 'react-use'; const Demo = ({url}) => { const state = useAsync(async () => { const response = await fetch(url); const result = await response.text(); return result }, [url]); return (
{state.loading ?
Loading...
: state.error ?
Error: {state.error.message}
:
Value: {state.value}
}
); }; ``` ## Reference ```ts useAsync(fn, args?: any[]); ```