Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. // ...
  2. export default (containerSize) => {
  3. // ...
  4. useEffect(() => {
  5. const onKeyDown = ({ which }) => act(ACTION.KEY_DOWN, which)
  6. const onKeyUp = ({ which }) => act(ACTION.KEY_UP, which)
  7. const tick = () => act(ACTION.TICK)
  8.  
  9. const timerId = setInterval(tick, UPDATE_EVERY)
  10. const unregisterKeydown = registerListener('keydown', onKeyDown)
  11. const unregisterKeyup = registerListener('keyup', onKeyUp)
  12. return () => {
  13. clearInterval(timerId)
  14. unregisterKeydown()
  15. unregisterKeyup()
  16. }
  17. }, [])
  18. // ...
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement