import { useEffect } from 'react' ; type Unsubscribe = ( ) => void | undefined ; export const useAsyncEffect = ( asyncCallback , deps ? ) => { useEffect ( ( ) => { const promise = asyncCallback ( ) ; return ( ) => { promise . then ( ( unsubscribe ) => unsubscribe && unsubscribe ( ) , e => console . error ( e ) ) ; } ; } , deps ) ; } ;