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

react-addons-clicked-away-mixin

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-addons-clicked-away-mixin

A React mixin for your React component when you need to know if the user clicks "away" from from the component.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Weekly downloads
 
Created
Source

react-addons-clicked-away-mixin

A React mixin for your React component when you need to know if the user clicks "away" from from the component.

Install

npm install react-addons-clicked-away-mixin --save

Usage

Below is a very simple example of toggling a "Menu":

CommonJS:

var ClickedAwayMixin = require('react-addons-clicked-away-mixin');
var React = require('react');
var ReactDOM = require('react-dom');

var Menu = React.createClass({

  getInitialState: function() {
    return {show: false};
  },
  
  mixins: [ClickedAwayMixin],

  render: function() {
    return (
      <div>
        <button type="button" onClick={this._toggleShow}>Toggle menu</button>
        {this.state.show && 
          <ul className="menu">
            <li>
              <a>Option A</a>
            </li>
            <li>
              <a>Option B</a>
            </li>
          </ul>
        }
      </div>
    );
  },
  
  onClickedAway: function() {
    if (this.state.open) this.setState({open: false});
  },
  
  _toggleShow: function() {
    this.setState({show: !this.state.show});
  }
  
});

var App = (
  <div>
    <Menu />
  </div>
);

ReactDOM.render(<App />, document.body);

Keywords

FAQs

Package last updated on 10 Feb 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