Attempt to at move app into app sub dir
This commit is contained in:
19
app/web/src/helpers/hooks/useKeyPress.js
Normal file
19
app/web/src/helpers/hooks/useKeyPress.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useRef, useEffect } from 'react'
|
||||
|
||||
const useKeyPress = (fn) => {
|
||||
const cb = useRef(fn)
|
||||
|
||||
useEffect(() => {
|
||||
cb.current = fn
|
||||
}, [fn])
|
||||
|
||||
useEffect(() => {
|
||||
const onUnload = cb.current
|
||||
|
||||
window.addEventListener('keydown', onUnload)
|
||||
|
||||
return () => window.removeEventListener('keydown', onUnload)
|
||||
}, [])
|
||||
}
|
||||
|
||||
export default useKeyPress
|
||||
Reference in New Issue
Block a user