MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / useEvent

Function useEvent

cli/src/hooks/use-event.ts:22–34  ·  view source on GitHub ↗
(callback: T)

Source from the content-addressed store, hash-verified

20 * <ChildComponent onClick={handleClick} />
21 */
22export function useEvent<T extends (...args: any[]) => any>(callback: T): T {
23 const callbackRef = useRef<T>(callback)
24
25 // Update the ref to the latest callback on every render
26 // This ensures the ref is always in sync with the current render
27 callbackRef.current = callback
28
29 // Return a stable function that calls the latest callback
30 return useCallback(
31 ((...args: any[]) => callbackRef.current(...args)) as T,
32 [], // Empty deps array ensures the function identity is stable
33 )
34}

Callers 2

ChatFunction · 0.90
ChatInputBarFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected