@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) • 699 B
TypeScript
import type { Fn } from '../@aileron/declare';
/**
* Executes a handler function when the component unmounts.
* Equivalent to returning a cleanup function from useEffect with an empty dependency array.
* @param handler - The function to execute on component unmount
*/
export declare const useOnUnmount: (handler: Fn) => void;
/**
* Executes a handler function when the component unmounts, before DOM updates.
* Similar to useOnUnmount but uses useLayoutEffect for synchronous execution.
* Useful for cleanup operations that need to run before DOM mutations.
* @param handler - The function to execute on component unmount
*/
export declare const useOnUnmountLayout: (handler: Fn) => void;