diff --git a/src/lifecycle/hooks/useMount/useMount.ts b/src/lifecycle/hooks/useMount/useMount.ts index c23b620..a7ba392 100644 --- a/src/lifecycle/hooks/useMount/useMount.ts +++ b/src/lifecycle/hooks/useMount/useMount.ts @@ -1,17 +1,24 @@ import { useEffect } from 'react'; + /** * React lifecycle hook that calls a function after the component is mounted. * @param callbackFunction function to be called when the component is mounted * * @example - * ``` * useMount(() => { * console.log('component is mounted'); * }) - * ``` + * + * useMount(async () => { + * console.log('component is mounted'); + * }) */ - -export function useMount(callbackFunction: () => void): void { - // eslint-disable-next-line react-hooks/exhaustive-deps - useEffect(callbackFunction, []); +export function useMount(callbackFunction: () => void | PromiseLike): void { + useEffect( + () => { + callbackFunction(); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [], + ); }