Tracks clicks outside its children
or clickRoots()
.
import {OutsideClick} from 'libreact/lib/OutsideClick';
<OutsideClick onClick={}>
<div>Don't click here.</div>
</OutsideClick>
import {OutsideClick} from 'libreact/lib/OutsideClick';
<OutsideClick onClick={} clickRoots={() => ([
document.getElementById('my-portal-root')
])}>
<div>Click anywhere outside `#my-portal-root` and my `onClick` will fire.</div>
</OutsideClick>
onClick
— event called when user click outside of its children.event
— optional, string, event name subscribe to, defaults tomousedown
.clickRoots
— optional, function that should return an array of DOM nodes. These should be considered where the user clicks inside, i.e. clicking outside of these roots will fireonClick
.