react-on-event-outside
v0.1.1
Published
Utility component for handling events outside the current component
Readme
React OnEventOutside
This package lets you listen to events outside of a component
Installation
npm i --save react-on-event-outsideUsage
OnEventOutside takes an on prop which is an object where the keys are the event type (e.g. click, mousedown, keyup, etc.) and the values are your callbacks.
import OnEventOutside from 'react-on-event-outside';
class MyComponent extends Component {
onClick(event) {
console.log('Somewhere else was clicked!', event);
}
render() {
return (
<OnEventOutside on={{
click: this.onClick
}}>
Don't click me, click somewhere else
</OnEventOutside>
);
}
}