How to use async function in useEffect?

Bond - Jul 23 - - Dev Community

Install ahooks and use useAsyncEffect.

Example:

  useAsyncEffect(async () => {
    setUser(await getUser());
  }, []);
Enter fullscreen mode Exit fullscreen mode

Note: This is bad practice. You should try other techniques instead of trying to run async functions inside useEffect.

.
Terabox Video Player