@restart/hooks
Advanced tools
Comparing version 0.4.13 to 0.4.14
@@ -14,2 +14,5 @@ export interface UseDebouncedCallbackOptions { | ||
* | ||
* > Heads up! debounced functions are not pure since they are called in a timeout | ||
* > Don't call them inside render. | ||
* | ||
* @param fn a function that will be debounced | ||
@@ -23,2 +26,5 @@ * @param waitOrOptions a wait in milliseconds or a debounce configuration | ||
* | ||
* > Heads up! debounced functions are not pure since they are called in a timeout | ||
* > Don't call them inside render. | ||
* | ||
* @param fn a function that will be debounced | ||
@@ -25,0 +31,0 @@ * @param waitOrOptions a wait in milliseconds or a debounce configuration |
@@ -7,2 +7,3 @@ "use strict"; | ||
var _useTimeout = _interopRequireDefault(require("./useTimeout")); | ||
var _useEventCallback = _interopRequireDefault(require("./useEventCallback")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -13,2 +14,5 @@ /** | ||
* | ||
* > Heads up! debounced functions are not pure since they are called in a timeout | ||
* > Don't call them inside render. | ||
* | ||
* @param fn a function that will be debounced | ||
@@ -22,2 +26,5 @@ * @param waitOrOptions a wait in milliseconds or a debounce configuration | ||
* | ||
* > Heads up! debounced functions are not pure since they are called in a timeout | ||
* > Don't call them inside render. | ||
* | ||
* @param fn a function that will be debounced | ||
@@ -33,2 +40,3 @@ * @param waitOrOptions a wait in milliseconds or a debounce configuration | ||
const lastArgsRef = (0, _react.useRef)(null); | ||
const handleCallback = (0, _useEventCallback.default)(fn); | ||
const { | ||
@@ -86,3 +94,3 @@ wait, | ||
lastInvokeTimeRef.current = time; | ||
const retValue = fn(...args); | ||
const retValue = handleCallback(...args); | ||
returnValueRef.current = retValue; | ||
@@ -123,5 +131,5 @@ return retValue; | ||
}; | ||
}, [fn, wait, maxWait, leading, trailing]); | ||
}, [handleCallback, wait, maxWait, leading, trailing]); | ||
} | ||
var _default = useDebouncedCallback; | ||
exports.default = _default; |
@@ -14,2 +14,5 @@ export interface UseDebouncedCallbackOptions { | ||
* | ||
* > Heads up! debounced functions are not pure since they are called in a timeout | ||
* > Don't call them inside render. | ||
* | ||
* @param fn a function that will be debounced | ||
@@ -23,2 +26,5 @@ * @param waitOrOptions a wait in milliseconds or a debounce configuration | ||
* | ||
* > Heads up! debounced functions are not pure since they are called in a timeout | ||
* > Don't call them inside render. | ||
* | ||
* @param fn a function that will be debounced | ||
@@ -25,0 +31,0 @@ * @param waitOrOptions a wait in milliseconds or a debounce configuration |
import { useMemo, useRef } from 'react'; | ||
import useTimeout from './useTimeout'; | ||
import useEventCallback from './useEventCallback'; | ||
@@ -8,2 +9,5 @@ /** | ||
* | ||
* > Heads up! debounced functions are not pure since they are called in a timeout | ||
* > Don't call them inside render. | ||
* | ||
* @param fn a function that will be debounced | ||
@@ -17,2 +21,5 @@ * @param waitOrOptions a wait in milliseconds or a debounce configuration | ||
* | ||
* > Heads up! debounced functions are not pure since they are called in a timeout | ||
* > Don't call them inside render. | ||
* | ||
* @param fn a function that will be debounced | ||
@@ -28,2 +35,3 @@ * @param waitOrOptions a wait in milliseconds or a debounce configuration | ||
const lastArgsRef = useRef(null); | ||
const handleCallback = useEventCallback(fn); | ||
const { | ||
@@ -81,3 +89,3 @@ wait, | ||
lastInvokeTimeRef.current = time; | ||
const retValue = fn(...args); | ||
const retValue = handleCallback(...args); | ||
returnValueRef.current = retValue; | ||
@@ -118,4 +126,4 @@ return retValue; | ||
}; | ||
}, [fn, wait, maxWait, leading, trailing]); | ||
}, [handleCallback, wait, maxWait, leading, trailing]); | ||
} | ||
export default useDebouncedCallback; |
{ | ||
"name": "@restart/hooks", | ||
"version": "0.4.13", | ||
"version": "0.4.14", | ||
"main": "cjs/index.js", | ||
@@ -5,0 +5,0 @@ "types": "cjs/index.d.ts", |
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
195722
5460