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
Martins ad network.