Piplup
@piplup/utilsHooks

useEventCallback

Creates a stable callback hook that preserves function identity between renders.

import { useEventCallback } from "@piplup/utils";

function Component() {
  const handle = useEventCallback((value: string) => {
    console.log(value);
  });

  return <button onClick={() => handle('hi')}>Click</button>;
}

Props

Prop

Type

Return value

Prop

Type

On this page