Skip to main content

useEvent

Callable


  • Returns a stable version of the provided callback function that can be safely passed to other hooks that depend on it. This is achieved by creating a mutable ref object that contains both the original callback function and the stable version. The stable version is created by calling the original callback function with the current arguments. When the provided callback function changes, the ref object is updated to contain the new callback function, effectively creating a new stable version.

    @see

    Type parameters

    • T: (...args: any[]) => any

    Parameters

    • callback: T

      the original callback function to create a stable version of

    Returns CallbackFn<T>

    A stable version of the provided callback function