react-hotkeys-hook
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -0,1 +1,5 @@ | ||
## [1.5.2] - 24-Aug-2019 | ||
* Update readme. | ||
* Bump hotkeys version to 3.7.1 | ||
## [1.5.1] - 21-Jul-2019 | ||
@@ -2,0 +6,0 @@ * Update readme. |
@@ -19,1 +19,2 @@ 'use strict'; | ||
exports.useHotkeys = useHotkeys; | ||
//# sourceMappingURL=index.js.map |
import hotkeys from 'hotkeys-js'; | ||
import { useCallback, useEffect } from 'react'; | ||
function useHotkeys(keys, callback) { | ||
let deps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
const memoisedCallback = useCallback(callback, deps); | ||
useEffect(() => { | ||
hotkeys(keys, memoisedCallback); | ||
return () => hotkeys.unbind(keys); | ||
}, [memoisedCallback]); | ||
function useHotkeys(keys, callback, deps = []) { | ||
const memoisedCallback = useCallback(callback, deps); | ||
useEffect(() => { | ||
hotkeys(keys, memoisedCallback); | ||
return () => hotkeys.unbind(keys); | ||
}, [memoisedCallback]); | ||
} | ||
export { useHotkeys }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-hotkeys-hook", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"license": "MIT", | ||
@@ -25,3 +25,3 @@ "files": [ | ||
"dependencies": { | ||
"hotkeys-js": "3.6.12" | ||
"hotkeys-js": "3.7.1" | ||
}, | ||
@@ -36,15 +36,15 @@ "peerDependencies": { | ||
"@babel/preset-typescript": "7.3.3", | ||
"@emotion/core": "10.0.14", | ||
"@pika/pack": "0.4.0", | ||
"@pika/plugin-build-node": "0.4.0", | ||
"@pika/plugin-build-types": "0.4.0", | ||
"@pika/plugin-build-web": "0.4.0", | ||
"@pika/plugin-ts-standard-pkg": "0.4.0", | ||
"@types/react": "16.8.23", | ||
"@types/react-dom": "16.8.4", | ||
"@emotion/core": "10.0.16", | ||
"@pika/pack": "0.5.0", | ||
"@pika/plugin-build-node": "0.6.0", | ||
"@pika/plugin-build-types": "0.6.0", | ||
"@pika/plugin-build-web": "0.6.0", | ||
"@pika/plugin-ts-standard-pkg": "0.6.0", | ||
"@types/react": "16.9.2", | ||
"@types/react-dom": "16.9.0", | ||
"docz": "1.2.0", | ||
"docz-theme-default": "1.2.0", | ||
"emotion-theming": "10.0.14", | ||
"react": "16.8.6", | ||
"react-dom": "16.8.6", | ||
"react": "16.9.0", | ||
"react-dom": "16.9.0", | ||
"typescript": "3.5.3" | ||
@@ -51,0 +51,0 @@ }, |
@@ -26,3 +26,5 @@ # react-hotkeys-hook | ||
```typescript jsx | ||
export const ExampleComponent: React.FunctionComponent<{}> = () => { | ||
import { useHotkeys } from 'react-hotkeys-hook'; | ||
export const ExampleComponent: React.FC = () => { | ||
const [count, setCount] = useState(0); | ||
@@ -85,2 +87,9 @@ useHotkeys('ctrl+k', () => setCount(prevCount => prevCount + 1)); | ||
### Local Development | ||
Checkout this repo, run `yarn` or `npm i` and then run the `docz:dev` script. | ||
You can use the `docs/useHotkeys.mdx` to test the behavior of the hook. It directly imports the | ||
`src/index.ts` file and transpiles it automatically. So you don't have to worry about. For more info | ||
on .mdx files, check out the docz documentation: https://www.docz.site/docs/writing-mdx | ||
### Authors | ||
@@ -87,0 +96,0 @@ |
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
10093
10
38
104
+ Addedhotkeys-js@3.7.1(transitive)
- Removedhotkeys-js@3.6.12(transitive)
Updatedhotkeys-js@3.7.1