diff --git a/client/utils/custom-hooks.js b/client/utils/custom-hooks.js index d88066a5..cf6c0130 100644 --- a/client/utils/custom-hooks.js +++ b/client/utils/custom-hooks.js @@ -52,3 +52,8 @@ export const useEffectWithComparison = (fn, props) => { update(props); }, Object.values(props)); }; + +export const useEventListener = (event, callback, useCapture = false) => useEffect(() => { + document.addEventListener(event, callback, useCapture); + return document.removeEventListener(event, callback, useCapture); +}, []);