useClickOutside

triggers a callback when you click outside of an element

Demo

Usage

const [const isOpen: booleanisOpen, const setIsOpen: (value: Kaioken.StateSetter<boolean>) => voidsetIsOpen] = useState<boolean>(initial: boolean | (() => boolean)): readonly [boolean, (value: Kaioken.StateSetter<boolean>) => void]useState(false)
const const ref: Kaioken.MutableRefObject<HTMLElement | null>ref = useRef<HTMLElement | null>(initialValue: HTMLElement | null): Kaioken.MutableRefObject<HTMLElement | null> (+2 overloads)useRef<HTMLElement | null>(null)
useClickOutside<ClickOutsideOptions>(ref: Kaioken.MutableRefObject<Element | null>, handler: ClickOutsideHandler<{
    detectIframe: boolean | undefined;
}>, options?: ClickOutsideOptions | undefined): void
useClickOutside
(const ref: Kaioken.MutableRefObject<HTMLElement | null>ref, () => {
const setIsOpen: (value: Kaioken.StateSetter<boolean>) => voidsetIsOpen(false) })