click-outside-react

1.0.2 • Public • Published

npm version

click-outside-react

Installation

npm install --save click-outside-react

Usage

import React, { Component } from 'react'
import { ClickOutside } from 'click-outside-react'

export default class Demo extends Component {
    state = {
        isPopupVisible: false
    }

    showPopup = () => {
        this.setState({ isPopupVisible: true })
    }

    hidePopup = () => {
        this.setState({ isPopupVisible: false })
    }

    render() {
        const { isPopupVisible } = this.state

        return (
            <div>
                {isPopupVisible
                    ? <ClickOutside onClickOutside={this.hidePopup}>Popup Content</ClickOutside>
                    : null
                }
            </div>
        )
    }
}

TODO

  • d.ts file
  • tests coverage

Readme

Keywords

Package Sidebar

Install

npm i click-outside-react

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

11.8 kB

Total Files

11

Last publish

Collaborators

  • salikovpro