Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-event-listener

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-event-listener

A React component that allow to bind events on the global scope

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
268K
decreased by-23.23%
Maintainers
1
Weekly downloads
 
Created
Source

React event listener

A React component for binding events on the global scope.

npm version npm downloads Build Status

Dependencies DevDependencies

Getting Started

npm install react-event-listener

Usage

import React from 'react';
import EventListener from 'react-event-listener';

class MyComponent extends React.Component {
  handleResize = () => {
    console.log('resize');
  };

  handleMouseMove = () => {
    console.log('mousemove');
  };

  render() {
    return (
      <div>
        <EventListener elementName="document" onMouseMove={this.handleMouseMove} />
        <EventListener elementName="window" onResize={this.handleResize} />
      </div>
    );
  }
}

Note on Testing

In this issue from React, TestUtils.Simulate. methods won't bubble up to window or document. As a result, you must use document.dispatchEvent or simulate event using native DOM api.

See our test cases for more information.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

MIT

Keywords

FAQs

Package last updated on 30 Apr 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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc