point 8 from Nick's list

This commit is contained in:
ajaythapliyal
2023-02-28 07:47:34 +05:30
parent 5bddee2d3e
commit 8e839cf80c
3 changed files with 28 additions and 11 deletions

View File

@@ -3,7 +3,7 @@ import { useEffect, RefObject } from 'react';
export function useOutsideAlerter<T extends HTMLElement>(
ref: RefObject<T>,
handler: () => void,
deps: any[],
additionalDeps: unknown[],
) {
useEffect(() => {
function handleClickOutside(this: Document, event: MouseEvent) {
@@ -15,5 +15,5 @@ export function useOutsideAlerter<T extends HTMLElement>(
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, [ref, ...deps]);
}, [ref, ...additionalDeps]);
}