@restart/hooks
Advanced tools
Comparing version 0.3.9 to 0.3.10
@@ -25,12 +25,9 @@ "use strict"; | ||
function useForceUpdate() { | ||
var _useState = (0, _react.useState)(false), | ||
setState = _useState[1]; // The toggling state value is designed to defeat React optimizations for skipping | ||
// updates when they are stricting equal to the last state value | ||
// The toggling state value is designed to defeat React optimizations for skipping | ||
var _useReducer = (0, _react.useReducer)(function (state) { | ||
return !state; | ||
}, false), | ||
dispatch = _useReducer[1]; | ||
return (0, _react.useCallback)(function () { | ||
return setState(function (value) { | ||
return !value; | ||
}); | ||
}, []); | ||
return dispatch; | ||
} |
@@ -36,7 +36,7 @@ "use strict"; | ||
var nextState = update(state); | ||
return nextState == null ? state : _extends({}, state, nextState); | ||
return nextState == null ? state : _extends({}, state, {}, nextState); | ||
}); | ||
} else { | ||
setState(function (state) { | ||
return _extends({}, state, update); | ||
return _extends({}, state, {}, update); | ||
}); | ||
@@ -43,0 +43,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { useCallback, useState } from 'react'; | ||
import { useReducer } from 'react'; | ||
/** | ||
@@ -20,12 +20,9 @@ * Returns a function that triggers a component update. the hook equivalent to | ||
export default function useForceUpdate() { | ||
var _useState = useState(false), | ||
setState = _useState[1]; // The toggling state value is designed to defeat React optimizations for skipping | ||
// updates when they are stricting equal to the last state value | ||
// The toggling state value is designed to defeat React optimizations for skipping | ||
var _useReducer = useReducer(function (state) { | ||
return !state; | ||
}, false), | ||
dispatch = _useReducer[1]; | ||
return useCallback(function () { | ||
return setState(function (value) { | ||
return !value; | ||
}); | ||
}, []); | ||
return dispatch; | ||
} |
@@ -31,7 +31,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
var nextState = update(state); | ||
return nextState == null ? state : _extends({}, state, nextState); | ||
return nextState == null ? state : _extends({}, state, {}, nextState); | ||
}); | ||
} else { | ||
setState(function (state) { | ||
return _extends({}, state, update); | ||
return _extends({}, state, {}, update); | ||
}); | ||
@@ -38,0 +38,0 @@ } |
{ | ||
"name": "@restart/hooks", | ||
"version": "0.3.9", | ||
"version": "0.3.10", | ||
"main": "cjs/index.js", | ||
@@ -16,2 +16,7 @@ "types": "cjs/index.d.ts", | ||
}, | ||
"prettier": { | ||
"singleQuote": true, | ||
"semi": false, | ||
"trailingComma": "all" | ||
}, | ||
"publishConfig": { | ||
@@ -18,0 +23,0 @@ "access": "public" |
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
115633
139
3063