Installation
npx shadcn@latest add @craftdotui/use-callback
Usage
import { useCallbackRef } from "@/hooks/use-callback";
function MyComponent() {
const handleClick = useCallbackRef(() => {
console.log("Button clicked!");
});
return <button onClick={handleClick}>Click me</button>;
}
API Reference
useCallbackRef
A hook that provides a stable callback reference while always invoking the latest version of the provided function.
| Parameter | Type | Description |
|---|---|---|
| callback | T | undefined | The callback function to be referenced |