UNPKG

529 BJavaScriptView Raw
1import * as React from 'react';
2export default function useEvent(callback) {
3 var fnRef = React.useRef();
4 fnRef.current = callback;
5 var memoFn = React.useCallback(function () {
6 var _fnRef$current;
7 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8 args[_key] = arguments[_key];
9 }
10 return (_fnRef$current = fnRef.current) === null || _fnRef$current === void 0 ? void 0 : _fnRef$current.call.apply(_fnRef$current, [fnRef].concat(args));
11 }, []);
12 return memoFn;
13}
\No newline at end of file