use-throttled-effect
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -10,7 +10,11 @@ 'use strict'; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var useThrottledEffect = exports.useThrottledEffect = function useThrottledEffect(callback, limit) { | ||
// const [throttledValue, setThrottledValue] = useState(value); | ||
var deps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
var lastRan = (0, _react.useRef)(Date.now()); | ||
(0, _react.useEffect)(function () { | ||
console.log([limit].concat(_toConsumableArray(deps))); | ||
var handler = setTimeout(function () { | ||
@@ -26,3 +30,5 @@ if (Date.now() - lastRan.current >= limit) { | ||
}; | ||
}, [callback, limit]); | ||
}; | ||
}, [limit].concat(_toConsumableArray(deps))); | ||
}; | ||
exports.default = useThrottledEffect; |
{ | ||
"name": "use-throttled-effect", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Throttled effect hook for react", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
4423
42