# `useAsyncCallback` React hook that returns state and a callback for an `async` function or a function that returns a promise. The state is of the same shape as `useAsync`. ## Usage ```jsx import {useAsyncCallback} from 'react-use'; const Demo = (url) => { const [state, fetch] = useAsyncCallback(async () => { const response = await fetch(url); const result = await response.text(); return result }), [url]; return (
{state.loading ?
Loading...
: state.error ?
Error: {state.error.message}
: state.value &&
Value: {state.value}
}
); }; ``` ## Reference ```ts useAsyncCallback(fn, deps?: any[]); ```