@shopify/react-hooks
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -10,2 +10,8 @@ # Changelog | ||
## [1.6.1] - 2020-04-07 | ||
### Fixed | ||
- `useOnChangeValue` is now executed in an `useEffect` and doesn't block the render method anymore. **This fix may cause timing issue in your project if you depended on the change handler happening synchronously.** | ||
## [1.6.0] - 2020-03-02 | ||
@@ -12,0 +18,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var react_1 = tslib_1.__importDefault(require("react")); | ||
var react_1 = tslib_1.__importStar(require("react")); | ||
function useOnValueChange(value, onChange) { | ||
var tracked = react_1.default.useRef(value); | ||
var oldValue = tracked.current; | ||
if (value !== oldValue) { | ||
tracked.current = value; | ||
onChange(value, oldValue); | ||
} | ||
react_1.useEffect(function () { | ||
var oldValue = tracked.current; | ||
if (value !== tracked.current) { | ||
tracked.current = value; | ||
onChange(value, oldValue); | ||
} | ||
}, [value, onChange]); | ||
} | ||
exports.useOnValueChange = useOnValueChange; |
{ | ||
"name": "@shopify/react-hooks", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "A collection of primitive React hooks.", |
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
16249
164