# `useAsyncRetry` Uses `useAsync` with an additional `retry` method to easily retry/refresh the async function; ## Usage ```jsx import {useAsyncRetry} from 'react-use'; // Returns a Promise that resolves after one second. const fn = () => new Promise((resolve, reject) => { setTimeout(() => { if (Math.random() > 0.5) { reject(new Error('Random error!')); } else { resolve('RESOLVED'); } }, 1000); }); const Demo = () => { const state = useAsync(fn); return (
{state.loading?
Loading...
: state.error?
Error...
:
Value: {state.value}
} {!state.loading? state.retry()}>Retry : null }
); }; ``` ## Reference ```ts useAsyncRetry(fn, args?: any[]); ```