useClickOutside

useClickOutside

import useClickOutside from "@kiwicom/orbit-components/lib/hooks/useClickOutside";
const App = () => {
const elementRef = React.useRef<HTMLDivElement | null>(null);
const handleClickOutside = ev => console.log(`The following event was detected: ${ev}`);
useClickOutside(elementRef, handleClickOutside);
return (
<div ref={elementRef}>
<span>Any click outside the parent div will trigger a log of the event.</span>
</div>
);
};