UNPKG

@hypothesis/frontend-shared

Version:

Shared components, styles and utilities for Hypothesis projects

10 lines (9 loc) 485 B
/** * Return a function which wraps a callback to give it a stable value. * * The wrapper has a stable value across renders, but always forwards to the * callback from the most recent render. This is useful if you want to use a * callback inside a `useEffect` or `useMemo` hook without re-running the effect * or re-computing the memoed value when the callback changes. */ export declare function useStableCallback<R, A extends any[], F extends (...a: A) => R>(callback: F): F;