A hook that executes a onClickOutside if a click occurs outside attached element ref.
callback handler
ref to attach to DOM element
Listen for clicks outside of an element.
import { useClickOutside } from "@trashpanda001/helpers/react"function Component() { const ref = useClickOutside((event) => { console.log("Clicked outside of element", event) }) return <div ref={ref}>Click outside of this element</div>} Copy
import { useClickOutside } from "@trashpanda001/helpers/react"function Component() { const ref = useClickOutside((event) => { console.log("Clicked outside of element", event) }) return <div ref={ref}>Click outside of this element</div>}
A hook that executes a onClickOutside if a click occurs outside attached element ref.