score:0

async in useeffect should be considered an antipattern (here an explanation) and you should get a warning like warning: an effect function must not return anything besides a function, which is used for clean-up.. not only but your useeffect has a missing dependency: listsomedatahandler.

in this case, much better call an async function inside the useeffect (and move listsomedatahandler inside useeffect). so your code becomes:

useeffect(() => {
    const listsomedatahandler = async (status) => {
      await listsomedata(status);
    };

    (async () => {
      promise.all(
        loadedstatus.map((status) => {
          return listsomedatahandler(status);
        })
      );
    })();
  }, [loadedstatus]);

here i made a codesandbox example and, as you can see, listsomedatahandler will be called 5 times.


Related Query

More Query from same tag