项目作者: fantua

项目描述 :
React component for handling outside clicks
高级语言: JavaScript
项目地址: git://github.com/fantua/react-outside-component.git
创建时间: 2017-11-19T19:56:00Z
项目社区:https://github.com/fantua/react-outside-component

开源协议:MIT License

下载


react-outside-component

React component for handling outside clicks. Inspired by reactstrap.

npm version

Installation

  1. yarn add react-outside-component

Api

Properties

  1. OutsideComponent.propTypes = {
  2. tag: PropTypes.string, // default 'div'
  3. isOpen: PropTypes.bool, // default true
  4. children: PropTypes.node,
  5. onClickOutside: PropTypes.func.isRequired,
  6. };

Example

  1. import React, { Component } from 'react';
  2. import Outside from 'react-outside-component';
  3. export default class CustomDropdown extends Component {
  4. constructor(props) {
  5. super(props);
  6. this.handleOutsideClick = this.handleOutsideClick.bind(this);
  7. }
  8. handleOutsideClick(e) {
  9. // ...
  10. }
  11. render() {
  12. return (
  13. <Outside tag="ul" className="dropdown-menu" onClickOutside={this.handleOutsideClick}>
  14. <li>Items..</li>
  15. </Outside>
  16. );
  17. }
  18. }

License

MIT