react-selectable-box
Version:
A React component used hooks that allows you to select elements in the drag area using the mouse
15 lines (14 loc) • 596 B
JavaScript
import { useCallback, useRef } from 'react';
// eslint-disable-next-line @typescript-eslint/ban-types
export default function useEvent(callback) {
var fnRef = useRef(callback);
fnRef.current = callback;
var memoFn = useCallback(function () {
var _fnRef$current;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return (_fnRef$current = fnRef.current) === null || _fnRef$current === void 0 ? void 0 : _fnRef$current.call.apply(_fnRef$current, [fnRef].concat(args));
}, []);
return memoFn;
}