How to use async function in useEffect?

Install ahooks and use useAsyncEffect.

Example:

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

Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
This includes providing resources and support for anyone looking to optimize their use of our cloud data storage solutions. Artificial intelligence solid future. Privacy, cookie & data policy.