UNPKG

use-dom-outside-click

Version:

react hook to handle outside click on elements

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