0.1.1 • Published 6 years ago

react-on-event-outside v0.1.1

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
6 years ago

React OnEventOutside

License npm version Build Status Codacy Badge

This package lets you listen to events outside of a component

Installation

npm i --save react-on-event-outside

Usage

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>
    );
  }
}