MCPcopy
hub / github.com/bbycroft/llm-viz / useFunctionRef

Function useFunctionRef

src/utils/hooks.ts:3–9  ·  view source on GitHub ↗
(fn: T)

Source from the content-addressed store, hash-verified

1import { useEffect, useReducer, useRef, useState } from "react";
2
3export function useFunctionRef<T extends ((...args: any[]) => any) | undefined>(fn: T): React.MutableRefObject<T> {
4 let ref = useRef<T>(fn);
5 useEffect(() => {
6 ref.current = fn;
7 }, [fn]);
8 return ref;
9}
10
11export function useRequestAnimationFrame(active: boolean, cb: (dt: number) => void) {
12 let cbRef = useFunctionRef(cb);

Callers 10

useResizeChangeHandlerFunction · 0.90
useGlobalKeyboardFunction · 0.90
useGlobalDragFunction · 0.90
useTouchEventsFunction · 0.90
QueryUpdaterFunction · 0.90
useRequestAnimationFrameFunction · 0.85
useIntervalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected