How to use async function in useEffect?



This content originally appeared on DEV Community and was authored by Bond

Install ahooks and use useAsyncEffect.

Example:

  useAsyncEffect(async () => {
    setUser(await getUser());
  }, []);


This content originally appeared on DEV Community and was authored by Bond