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.
14 lines
384 B
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;
|
|
} |