The React hook 'useEffect', but asynchroneous.
The React hook 'useEffect', but asynchroneous.
``js
useAsyncEffect(async () => {
await somethingAsync();
return async () => {
// the cleanup code can be async too
}
}, [dep1, dep2])
`
It's optional but a logger can be configured:
`jsx`
{/ your application here /}
When a logger is configured, then useAsyncEffect catches all the errors and calls logger.error`.