Files
2026-08-07 21:39:30 +02:00

13 lines
732 B
TypeScript

type Callback = (...args: any[]) => any;
/**
* Stabilizes the function passed so it's always the same between renders.
*
* The function becomes non-reactive to any values it captures.
* It can safely be passed as a dependency of `React.useMemo` and `React.useEffect` without re-triggering them if its captured values change.
*
* The function must only be called inside effects and event handlers, never during render (which throws an error).
*
* This hook is a more permissive version of React 19.2's `React.useEffectEvent` in that it can be passed through contexts and called in event handler props, not just effects.
*/
export declare function useStableCallback<T extends Callback>(callback: T | undefined): T;
export {};