Comparing version 2.7.0 to 2.7.1
@@ -1,6 +0,5 @@ | ||
/// <reference types="lodash" /> | ||
import { DebounceOptions } from '../useDebounce/debounceOptions'; | ||
declare type Fn = (...args: any) => any; | ||
declare function useDebounceFn<T extends Fn>(fn: T, options?: DebounceOptions): { | ||
run: T & import("lodash").Cancelable; | ||
run: T; | ||
cancel: () => void; | ||
@@ -7,0 +6,0 @@ flush: () => void; |
@@ -5,4 +5,4 @@ import { useEffect, useRef } from 'react'; | ||
var immediate = options === null || options === void 0 ? void 0 : options.immediate; | ||
var timerRef = useRef(); | ||
timerRef.current = fn; | ||
var fnRef = useRef(); | ||
fnRef.current = fn; | ||
useEffect(function () { | ||
@@ -14,3 +14,3 @@ var _a; | ||
if (immediate) { | ||
(_a = timerRef.current) === null || _a === void 0 ? void 0 : _a.call(timerRef); | ||
(_a = fnRef.current) === null || _a === void 0 ? void 0 : _a.call(fnRef); | ||
} | ||
@@ -21,3 +21,3 @@ | ||
(_a = timerRef.current) === null || _a === void 0 ? void 0 : _a.call(timerRef); | ||
(_a = fnRef.current) === null || _a === void 0 ? void 0 : _a.call(fnRef); | ||
}, delay); | ||
@@ -24,0 +24,0 @@ return function () { |
@@ -18,3 +18,4 @@ var __values = this && this.__values || function (o) { | ||
import { useEffect, useCallback, useRef } from 'react'; | ||
import { useEffect, useRef } from 'react'; | ||
import usePersistFn from '../usePersistFn'; | ||
import { getTargetElement } from '../utils/dom'; // 键盘事件 keyCode 别名 | ||
@@ -180,3 +181,3 @@ | ||
callbackRef.current = eventHandler; | ||
var callbackHandler = useCallback(function (event) { | ||
var callbackHandler = usePersistFn(function (event) { | ||
var genGuard = genKeyFormater(keyFilter); | ||
@@ -187,3 +188,3 @@ | ||
} | ||
}, [keyFilter]); | ||
}); | ||
useEffect(function () { | ||
@@ -231,5 +232,5 @@ var e_2, _a; | ||
}; | ||
}, [events, callbackHandler, typeof target === 'function' ? undefined : target]); | ||
}, [events.join(''), callbackHandler, typeof target === 'function' ? undefined : target]); | ||
} | ||
export default useKeyPress; |
@@ -1,6 +0,5 @@ | ||
/// <reference types="lodash" /> | ||
import { ThrottleOptions } from '../useThrottle/throttleOptions'; | ||
declare type Fn = (...args: any) => any; | ||
declare function useThrottleFn<T extends Fn>(fn: T, options?: ThrottleOptions): { | ||
run: T & import("lodash").Cancelable; | ||
run: T; | ||
cancel: () => void; | ||
@@ -7,0 +6,0 @@ flush: () => void; |
@@ -1,6 +0,5 @@ | ||
/// <reference types="lodash" /> | ||
import { DebounceOptions } from '../useDebounce/debounceOptions'; | ||
declare type Fn = (...args: any) => any; | ||
declare function useDebounceFn<T extends Fn>(fn: T, options?: DebounceOptions): { | ||
run: T & import("lodash").Cancelable; | ||
run: T; | ||
cancel: () => void; | ||
@@ -7,0 +6,0 @@ flush: () => void; |
@@ -11,4 +11,4 @@ "use strict"; | ||
var immediate = options === null || options === void 0 ? void 0 : options.immediate; | ||
var timerRef = react_1.useRef(); | ||
timerRef.current = fn; | ||
var fnRef = react_1.useRef(); | ||
fnRef.current = fn; | ||
react_1.useEffect(function () { | ||
@@ -20,3 +20,3 @@ var _a; | ||
if (immediate) { | ||
(_a = timerRef.current) === null || _a === void 0 ? void 0 : _a.call(timerRef); | ||
(_a = fnRef.current) === null || _a === void 0 ? void 0 : _a.call(fnRef); | ||
} | ||
@@ -27,3 +27,3 @@ | ||
(_a = timerRef.current) === null || _a === void 0 ? void 0 : _a.call(timerRef); | ||
(_a = fnRef.current) === null || _a === void 0 ? void 0 : _a.call(fnRef); | ||
}, delay); | ||
@@ -30,0 +30,0 @@ return function () { |
@@ -20,2 +20,8 @@ "use strict"; | ||
var __importDefault = this && this.__importDefault || function (mod) { | ||
return mod && mod.__esModule ? mod : { | ||
"default": mod | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -27,2 +33,4 @@ value: true | ||
var usePersistFn_1 = __importDefault(require("../usePersistFn")); | ||
var dom_1 = require("../utils/dom"); // 键盘事件 keyCode 别名 | ||
@@ -189,3 +197,3 @@ | ||
callbackRef.current = eventHandler; | ||
var callbackHandler = react_1.useCallback(function (event) { | ||
var callbackHandler = usePersistFn_1["default"](function (event) { | ||
var genGuard = genKeyFormater(keyFilter); | ||
@@ -196,3 +204,3 @@ | ||
} | ||
}, [keyFilter]); | ||
}); | ||
react_1.useEffect(function () { | ||
@@ -240,5 +248,5 @@ var e_2, _a; | ||
}; | ||
}, [events, callbackHandler, typeof target === 'function' ? undefined : target]); | ||
}, [events.join(''), callbackHandler, typeof target === 'function' ? undefined : target]); | ||
} | ||
exports["default"] = useKeyPress; |
@@ -1,6 +0,5 @@ | ||
/// <reference types="lodash" /> | ||
import { ThrottleOptions } from '../useThrottle/throttleOptions'; | ||
declare type Fn = (...args: any) => any; | ||
declare function useThrottleFn<T extends Fn>(fn: T, options?: ThrottleOptions): { | ||
run: T & import("lodash").Cancelable; | ||
run: T; | ||
cancel: () => void; | ||
@@ -7,0 +6,0 @@ flush: () => void; |
{ | ||
"name": "ahooks", | ||
"version": "2.7.0", | ||
"version": "2.7.1", | ||
"description": "react hooks library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9072
374967