You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
InternshipProject/node_modules/rc-tree-select/es/hooks/useRefFunc.js

14 lines
384 B

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;
}