foxact
Version:
React Hooks/Utils done right. For browser, SSR, and React Server Components.
11 lines (9 loc) • 529 B
TypeScript
/**
* @see https://foxact.skk.moe/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired
* Similar to useCallback, with a few subtle differences:
* - The returned function is a stable reference, and will always be the same between renders
* - No dependency lists required
* - Properties or state accessed within the callback will always be "current"
*/
declare function useStableHandler<Args extends any[], Result>(callback: (...args: Args) => Result): typeof callback;
export { useStableHandler };