Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ...
- export default (containerSize) => {
- // ...
- useEffect(() => {
- const onKeyDown = ({ which }) => act(ACTION.KEY_DOWN, which)
- const onKeyUp = ({ which }) => act(ACTION.KEY_UP, which)
- const tick = () => act(ACTION.TICK)
- const timerId = setInterval(tick, UPDATE_EVERY)
- const unregisterKeydown = registerListener('keydown', onKeyDown)
- const unregisterKeyup = registerListener('keyup', onKeyUp)
- return () => {
- clearInterval(timerId)
- unregisterKeydown()
- unregisterKeyup()
- }
- }, [])
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement