react-hotkeys-hook
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -0,1 +1,5 @@ | ||
## [1.3.0] - 06-Apr-2019 | ||
* Fixed bind and unbind on every render | ||
* Updated docz to make it work with the new deps array | ||
## [1.2.0] - 30-Mar-2019 | ||
@@ -2,0 +6,0 @@ * Updated hotkeys |
@@ -12,9 +12,14 @@ 'use strict'; | ||
react.useEffect(() => { | ||
hotkeys(keys, (event, handler) => callback(event, handler)); | ||
console.log('calling bind'); | ||
hotkeys(keys, (event, handler) => { | ||
console.log('callback gets called'); | ||
callback(event, handler); | ||
}); | ||
return function () { | ||
console.log('calling unbind'); | ||
hotkeys.unbind(keys); | ||
}; | ||
}); | ||
}, []); | ||
} | ||
exports.useHotkeys = useHotkeys; |
@@ -5,7 +5,12 @@ import hotkeys from 'hotkeys-js'; | ||
useEffect(() => { | ||
hotkeys(keys, (event, handler) => callback(event, handler)); | ||
console.log('calling bind'); | ||
hotkeys(keys, (event, handler) => { | ||
console.log('callback gets called'); | ||
callback(event, handler); | ||
}); | ||
return function () { | ||
console.log('calling unbind'); | ||
hotkeys.unbind(keys); | ||
}; | ||
}); | ||
}, []); | ||
} |
@@ -6,9 +6,14 @@ import hotkeys from 'hotkeys-js'; | ||
useEffect(() => { | ||
hotkeys(keys, (event, handler) => callback(event, handler)); | ||
console.log('calling bind'); | ||
hotkeys(keys, (event, handler) => { | ||
console.log('callback gets called'); | ||
callback(event, handler); | ||
}); | ||
return function () { | ||
console.log('calling unbind'); | ||
hotkeys.unbind(keys); | ||
}; | ||
}); | ||
}, []); | ||
} | ||
export { useHotkeys }; |
{ | ||
"name": "react-hotkeys-hook", | ||
"description": "React hook for using keyboard shortcuts in components. This is a hook version for the [hotkeys] package.", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"license": "MIT", | ||
@@ -37,7 +37,7 @@ "source": "dist-src/index.js", | ||
"devDependencies": { | ||
"@babel/core": "7.4.0", | ||
"@babel/preset-env": "7.4.2", | ||
"@babel/core": "7.4.3", | ||
"@babel/preset-env": "7.4.3", | ||
"@babel/preset-react": "7.0.0", | ||
"@babel/preset-typescript": "7.3.3", | ||
"@emotion/core": "10.0.6", | ||
"@emotion/core": "10.0.10", | ||
"@pika/pack": "0.3.6", | ||
@@ -48,11 +48,11 @@ "@pika/plugin-build-node": "0.3.14", | ||
"@pika/plugin-ts-standard-pkg": "0.3.14", | ||
"@types/react": "16.8.10", | ||
"@types/react": "16.8.12", | ||
"@types/react-dom": "16.8.3", | ||
"docz": "0.13.7", | ||
"docz-theme-default": "0.13.7", | ||
"emotion-theming": "10.0.6", | ||
"emotion-theming": "10.0.10", | ||
"react": "16.8.6", | ||
"react-dom": "16.8.6", | ||
"typescript": "3.4.1" | ||
"typescript": "3.4.2" | ||
} | ||
} |
@@ -28,3 +28,3 @@ # react-hotkeys-hook | ||
const [count, setCount] = useState(0); | ||
useHotkeys('ctrl+k', () => setCount(count + 1)); | ||
useHotkeys('ctrl+k', () => setCount(prevCount => prevCount + 1)); | ||
@@ -43,3 +43,3 @@ return ( | ||
const [count, setCount] = useState(0); | ||
useHotkeys('ctrl+k', () => setCount(count + 1)); | ||
useHotkeys('ctrl+k', () => setCount(prevCount => prevCount + 1)); | ||
@@ -46,0 +46,0 @@ return ( |
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
6652
52