react-use icon indicating copy to clipboard operation
react-use copied to clipboard

useAsync but with cleanup

Open mfulton26 opened this issue 3 years ago • 1 comments

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();
    };
  });

mfulton26 avatar Aug 29 '22 19:08 mfulton26

Has anyone developing this?

patrickjmeurer avatar Oct 20 '22 18:10 patrickjmeurer