useEventCallback

Custom hook that creates a memoized event callback.

Custom hook that creates a memoized event callback.

Usage

import { useEventCallback } from "@tilt-legal/cubitt-components/utilities/hooks";

const handleClick = useEventCallback((event) => {
  // Handle the event here
});

API

Signature

declare function useEventCallback<Args extends unknown[], R>(fn: (...args: Args) => R): (...args: Args) => R;
declare function useEventCallback<Args extends unknown[], R>(fn: ((...args: Args) => R) | undefined): ((...args: Args) => R) | undefined;

Parameters

ParameterTypeDescriptionDefault
fn(...args: Args) =&gt; RThe callback function.-

Return Value

ValueTypeDescription
return(...args: Args) =&gt; RA memoized event callback function.

On this page