react-use
Advanced tools
Comparing version 14.1.0 to 14.1.1
@@ -1,14 +0,6 @@ | ||
import { useCallback, useState } from 'react'; | ||
import { useReducer } from 'react'; | ||
var toggleReducer = function (state, nextValue) { return (typeof nextValue === 'boolean' ? nextValue : !state); }; | ||
var useToggle = function (initialValue) { | ||
var _a = useState(initialValue), value = _a[0], setValue = _a[1]; | ||
var toggle = useCallback(function (nextValue) { | ||
if (typeof nextValue === 'boolean') { | ||
setValue(nextValue); | ||
} | ||
else { | ||
setValue(function (currentValue) { return !currentValue; }); | ||
} | ||
}, [setValue]); | ||
return [value, toggle]; | ||
return useReducer(toggleReducer, initialValue); | ||
}; | ||
export default useToggle; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = require("react"); | ||
var toggleReducer = function (state, nextValue) { return (typeof nextValue === 'boolean' ? nextValue : !state); }; | ||
var useToggle = function (initialValue) { | ||
var _a = react_1.useState(initialValue), value = _a[0], setValue = _a[1]; | ||
var toggle = react_1.useCallback(function (nextValue) { | ||
if (typeof nextValue === 'boolean') { | ||
setValue(nextValue); | ||
} | ||
else { | ||
setValue(function (currentValue) { return !currentValue; }); | ||
} | ||
}, [setValue]); | ||
return [value, toggle]; | ||
return react_1.useReducer(toggleReducer, initialValue); | ||
}; | ||
exports.default = useToggle; |
{ | ||
"name": "react-use", | ||
"version": "14.1.0", | ||
"version": "14.1.1", | ||
"description": "Collection of React Hooks", | ||
@@ -49,3 +49,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@types/js-cookie": "2.2.5", | ||
"@types/js-cookie": "2.2.6", | ||
"@xobotyi/scrollbar-width": "1.9.5", | ||
@@ -100,9 +100,9 @@ "copy-to-clipboard": "^3.2.0", | ||
"eslint-plugin-react-hooks": "3.0.0", | ||
"fork-ts-checker-webpack-plugin": "4.1.2", | ||
"fork-ts-checker-webpack-plugin": "4.1.3", | ||
"gh-pages": "2.2.0", | ||
"husky": "4.2.3", | ||
"jest": "25.2.7", | ||
"husky": "4.2.5", | ||
"jest": "25.3.0", | ||
"jest-localstorage-mock": "2.4.0", | ||
"keyboardjs": "2.5.1", | ||
"lint-staged": "10.1.2", | ||
"lint-staged": "10.1.3", | ||
"markdown-loader": "5.1.0", | ||
@@ -158,3 +158,3 @@ "prettier": "2.0.4", | ||
"volta": { | ||
"node": "10.19.0", | ||
"node": "10.20.0", | ||
"yarn": "1.22.4" | ||
@@ -161,0 +161,0 @@ }, |
Sorry, the diff of this file is too big to display
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
456136
9172
+ Added@types/js-cookie@2.2.6(transitive)
- Removed@types/js-cookie@2.2.5(transitive)
Updated@types/js-cookie@2.2.6