Files
2026-01-16 02:20:32 +00:00

14 lines
384 B
JavaScript

import * as React from 'react';
/**
* Same as `React.useCallback` but always return a memoized function
* but redirect to real function.
*/
export default function useRefFunc(callback) {
var funcRef = React.useRef();
funcRef.current = callback;
var cacheFn = React.useCallback(function () {
return funcRef.current.apply(funcRef, arguments);
}, []);
return cacheFn;
}