Should I use IIFE in useEffect hook?
06:54 15 Mar 2022

Is it good practice to use IIFE in useEffect or I should declare async function and then call it?

  useEffect(() => {
    (async () => {
      const response = await fetch(
        "https://jsonplaceholder.typicode.com/posts"
      );
      const json = await response.json();

      setPosts(json);
    })();
  });
javascript reactjs react-hooks use-effect iife