This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
Releases: jxom/react-loads
Releases · jxom/react-loads
9.2.3
9.2.1
9.2.0
Features
- Add ability to debounce invocation of the async function, using the
debounce
config option. Example:
async function fetchRandomDog({ value }) {
const response = await axios.get(`https://dog.ceo/api/breed/${value}/images/random);
return response;
}
export default function RandomDog() {
const [value, setValue] = React.useState('poodle');
const { isPending, isResolved, response } = useLoads('random-dog', fetchRandomDog, {
debounce: 1000,
variables: [{ value }]
});
return (
<div>
<input
placeholder="Search for a dog..."
onChange={e => setValue(e.target.value)}
value={value}
/>
{isPending && 'Loading...'}
{isResolved && (
<img src={response.data.message} />
)}
</div>
)
}