Socket
Book a DemoInstallSign in
Socket

react-event-outside

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-event-outside

A Higher Order Component for listening mouse events outside of the component

1.3.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

ReactEventOutside Build Status npm version

A Higher Order Component for listening mouse events outside of the component

It's uses callback refs instead of ReactDOM.findDOMNode() (why).

Usage

Installation

npm install react-event-outside --save

Basic usage:

ReactEventOutside()(Component) /* listening for default "click" event */
ReactEventOutside(['wheel', 'dblclick'])(Component) /* listening for "wheel" and "dblclick" events */

Using ES6:

import React from 'react';
import ReactEventOutside from 'react-event-outside';

class ShareArea extends React.Component {
  constructor(props) {
    super(props);
    this.handleEvent = this.handleEvent.bind(this);
  }

  handleEvent(e) {
    /* your code */
  }

  render() {
    return <div>Nothing here...</div>
    );
  }
}

export default ReactEventOutside()(ShareArea);

Using ES7 decorator:

import React from 'react';
import ReactEventOutside from 'react-event-outside';

@ReactEventOutside()
class ShareArea extends React.Component {
  constructor(props) {
    super(props);
    this.handleEvent = this.handleEvent.bind(this);
  }

  handleEvent(e) {
    /* your code */
  }

  render() {
    return <div>Nothing here...</div>
    );
  }
}

export default ShareArea;

Notes

  • If handleEvent isn't implemented, nothing would happen.

License

MIT

Keywords

react

FAQs

Package last updated on 22 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.