Loading...
Please waitLoading...
Please waitpnpm dlx uselab@latest add use-callback-ref
import * as React from "react"
import { useCallbackRef } from "@/hooks/use-callback-ref"
export function Component() {
const handleClick = useCallbackRef((event: React.MouseEvent) => {
console.log("Button clicked!", event)
})
return <button onClick={handleClick}>Click Me</button>
}| Name | Type | Description | Default Value | Optional |
|---|---|---|---|---|
callback | T | undefined | The callback function to memoize, where T is a function type with any arguments and return value. Can be undefined. | undefined | Yes |
| Name | Type | Description |
|---|---|---|
callbackRef | T | undefined | A memoized version of the callback function that always uses the latest callback reference. |