reshow-hooks
Advanced tools
Comparing version 0.17.51 to 0.17.52
"use strict"; | ||
var _interopRequireDefault = require("reshow-runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
exports["default"] = void 0; | ||
var _react = require("react"); | ||
var _callFunc = _interopRequireDefault(require("call-func")); | ||
// @ts-check | ||
@@ -11,12 +13,21 @@ | ||
* @param {ValueType|function():ValueType} [value] | ||
* @param {function(ValueType):ValueType} [cookCb] | ||
* @return {React.MutableRefObject<ValueType|undefined>} | ||
*/ | ||
var useRefUpdate = function useRefUpdate(value) { | ||
var useRefUpdate = function useRefUpdate(value, cookCb) { | ||
if (cookCb === void 0) { | ||
cookCb = function cookCb(v) { | ||
return v; | ||
}; | ||
} | ||
var last = /** @type any*/(0, _react.useRef)(); | ||
if (last.current !== value) { | ||
last.current = value; | ||
var lastCook = /** @type any*/(0, _react.useRef)(); | ||
var nextValue = (0, _callFunc["default"])(value); | ||
if (last.current !== nextValue) { | ||
last.current = nextValue; | ||
lastCook.current = (0, _callFunc["default"])(cookCb, [value]); | ||
} | ||
return last; | ||
return lastCook; | ||
}; | ||
var _default = exports["default"] = useRefUpdate; | ||
module.exports = exports.default; |
{ | ||
"version": "0.17.51", | ||
"version": "0.17.52", | ||
"name": "reshow-hooks", | ||
@@ -4,0 +4,0 @@ "repository": { |
@@ -5,4 +5,5 @@ export default useRefUpdate; | ||
* @param {ValueType|function():ValueType} [value] | ||
* @param {function(ValueType):ValueType} [cookCb] | ||
* @return {React.MutableRefObject<ValueType|undefined>} | ||
*/ | ||
declare function useRefUpdate<ValueType>(value?: ValueType | (() => ValueType)): import("react").MutableRefObject<ValueType>; | ||
declare function useRefUpdate<ValueType>(value?: ValueType | (() => ValueType), cookCb?: (arg0: ValueType) => ValueType): import("react").MutableRefObject<ValueType>; |
Sorry, the diff of this file is not supported yet
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
45858
1344