(callback: T)
| 5 | * but redirect to real function. |
| 6 | */ |
| 7 | export default function useRefFunc<T extends (...args: any[]) => any>(callback: T): T { |
| 8 | const funcRef = React.useRef<T>(); |
| 9 | funcRef.current = callback; |
| 10 | |
| 11 | const cacheFn = React.useCallback((...args: any[]) => { |
| 12 | return funcRef.current(...args); |
| 13 | }, []); |
| 14 | |
| 15 | return cacheFn as any; |
| 16 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…