UNPKG

741 BJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4Object.defineProperty(exports, "__esModule", {
5 value: true
6});
7exports.default = useEvent;
8var React = _interopRequireWildcard(require("react"));
9function useEvent(callback) {
10 var fnRef = React.useRef();
11 fnRef.current = callback;
12 var memoFn = React.useCallback(function () {
13 var _fnRef$current;
14 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
15 args[_key] = arguments[_key];
16 }
17 return (_fnRef$current = fnRef.current) === null || _fnRef$current === void 0 ? void 0 : _fnRef$current.call.apply(_fnRef$current, [fnRef].concat(args));
18 }, []);
19 return memoFn;
20}
\No newline at end of file