react-use
react-use copied to clipboard
useAsync but with cleanup
Is your feature request related to a problem? Please describe.
I want to write a useEffect with a cleanup but I want to use await too
Describe the solution you'd like
A helpful hook like useAsync but that doesn't look for a return value but accepts a cleanup function like useEffect
Describe alternatives you've considered
using useEffect directly and defining an inline async functions to call and returning a cleanup function too
useEffect(() => {
const myAsyncSetup = async () => { /* ... */ };
myAsyncSetup();
return () => {
const myAsyncCleanup = async () => { /* ... */ };
myAsyncCleanup();
};
});
Has anyone developing this?