UNPKG

use-dom-outside-click

Version:

react hook to handle outside click on elements

3 lines (2 loc) 441 B
import{useEffect as n}from"react";var t=function(t,e,o){var r=function(n){(null==o?void 0:o.some((function(t){var e;return null===(e=null==t?void 0:t.current)||void 0===e?void 0:e.contains(n.target)})))||t.current&&!t.current.contains(n.target)&&e()};n((function(){return document.addEventListener("mousedown",r),function(){document.removeEventListener("mousedown",r)}}),[t])};export{t as useOutsideClick}; //# sourceMappingURL=index.js.map