UNPKG

@supunlakmal/hooks

Version:

A collection of reusable React hooks

12 lines (11 loc) 608 B
/** * Creates a stable callback function that always calls the latest version of the provided callback. * * Useful for optimizing child components that rely on stable function references (e.g., in `React.memo` or dependency arrays) * while ensuring the most up-to-date logic is executed. * * @template T Callback function type. * @param {T} callback The callback function whose latest version should always be invoked. * @returns {T} A stable function reference that delegates to the latest `callback`. */ export declare function useEventCallback<T extends (...args: any[]) => any>(callback: T): T;