Socket
Book a DemoInstallSign in
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
npmnpm
Version published
Maintainers
1
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

javascript

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

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.