useKeyup
Get window size by hooks keyup
event without side-effect.
Install
$ npm install use-keyup
How to use?
This example will auto removeEventListener when component unmounted.
;const demo = { const key setKey = ; ; return <p>keyup key</p>;};
Explicity Clean the handler.
;const demo = { const key setKey = ; const cleanUp = ; ; return <p>keyup key</p>;};
What I Do?
Call clean-up function (to removeEventListener
) when component has been unmounted.
Also, I export a cleanUp
function, you can use this to explicity remove events when you need.
useEventTarget
Why This has a dependency of This is a hooks infrastructure for easily package a event hooks.
See more useEventTarget.