UNPKG

rooks

Version:

Essential React custom hooks ⚓ to super charge your components!

18 lines (17 loc) 470 B
import { useEffect } from "react"; /** * useDidMount hook * @description Calls a function on mount * * @param {Function} callback Callback function to be called on mount * @see https://react-hooks.org/docs/useDidMount */ function useDidMount(callback) { useEffect(function () { if (typeof callback === "function") { callback(); } // eslint-disable-next-line react-hooks/exhaustive-deps }, []); } export { useDidMount };