@winglet/react-utils
Version:
React utility library providing custom hooks, higher-order components (HOCs), and utility functions to enhance React application development with improved reusability and functionality
15 lines (14 loc) • 682 B
TypeScript
import { type EffectCallback } from 'react';
/**
* Executes a handler function only once when the component mounts.
* Equivalent to useEffect with an empty dependency array.
* @param handler - The function to execute on component mount
*/
export declare const useOnMount: (handler: EffectCallback) => void;
/**
* Executes a handler function only once when the component mounts, before DOM updates.
* Similar to useOnMount but uses useLayoutEffect for synchronous execution.
* Useful for DOM measurements or preventing visual flicker.
* @param handler - The function to execute on component mount
*/
export declare const useOnMountLayout: (handler: EffectCallback) => void;