Skip to content
usefy

useEventCallback

Lifecycle & refs

A stable callback that always sees the latest props and state

Install

$ npm install @usefy/use-event-callback

Quick start

useEventCallback.tsx
import { useEventCallback } from "@usefy/use-event-callback";

const onClick = useEventCallback(() => console.log(count));
// stable identity, always reads the current count

API reference

useEventCallback<Args, R>(fn): (...args) => R — a referentially-stable function that proxies to the latest fn.

Go deeper

This page is the quick reference. For every example, prop, and edge case, read the full README — or open Storybook to change props live.

More in lifecycle & refs