Skip to content

useClickAway

Trigger a callback when clicking outside of an element

Usage

const App = () => {
const ref = useClickAway(() => console.log("Clicked outside!"));
return <div ref={ref}>Click outside of me</div>;
};

Installation

Terminal window
npx atmx add hook use-click-away