Socket
Socket
Sign inDemoInstall

@leafyjava/react-click-away

Package Overview
Dependencies
6
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @leafyjava/react-click-away

Use this component to wrap other components to detect if it is clicked outside of the wrapped container.


Version published
Weekly downloads
10
increased by233.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

react-click-away

Use this component to wrap other components to detect if it is clicked outside of the wrapped container.

NPM JavaScript Style Guide

Demo

https://zhenyanghua.github.io/react-click-away/

Install

npm install --save @leafyjava/react-click-away

Usage

import React from 'react'

import ClickOutside from '@leafyjava/react-click-away'

const App = () => {
  const [clicked, setClicked] = React.useState(false);

  const handleClickOutside = () => {
    setClicked(clicked => !clicked);
  }

  return (
    <div>
      <ClickOutside onClickOutside={handleClickOutside}>
        <h1>Click Outside of this Box to Toggle</h1>
      </ClickOutside>
      {clicked && <h1>Clicked Outside Toggled</h1>}
    </div>

  )
}

export default App

License

MIT © zhenyanghua

Keywords

FAQs

Last updated on 16 May 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc