Convenience function for usage of useEffect with async functions in React
npm install @jeswr/use-async-effectConvenience function for usage of useEffect with async functions in React.





Convenience and makes code cleaner. The following is allowed
``ts
import { useAsyncEffect } from "@jeswr/use-async-effect";
function MyComponent() {
useAsyncEffect(async () => {
/ Effect goes here /
}, []);
return / JSX Output /
}
`
in constrast, async function calls with useEffect in React should be structured as follows:
`ts
import { useEffect } from "react";
function MyComponent() {
useEffect(() => {
(async () => {
/ Effect goes here /
})();
}, []);
return / JSX Output /
}
``
©2021–present
Jesse Wright,
MIT License.