Socket
Socket
Sign inDemoInstall

react-click-outside-hook

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-click-outside-hook

Simple to use React Hook with click outside functionality


Version published
Weekly downloads
2.9K
increased by11.37%
Maintainers
1
Install size
19.8 kB
Created
Weekly downloads
 

Readme

Source

react-click-outside-hook 🎣

Version Badge GZipped size Build Status Coverage Status License Downloads styled with prettier

React Hook implementation with click outside functionality.

Features

  • 👆 Support for pointer and touch events
  • 🎣 Made with 💖 by React Hooks - Easy to use API thanks to React Hooks
  • 💥 Tiny bundle ~850 bytes gzipped

Installation

Install using Yarn:

yarn add react-click-outside-hook

or NPM:

npm install react-click-outside-hook --save

Usage 🎣

useClickOutside
const [ref, hasClickedOutside] = useClickOutside()

The new React Hooks make it easier than ever to monitor the hasClickedOutside state of your components. Call the useClickOutside hook which will return an array containing a ref and the hasClickedOutside status. Simply assign the ref to the DOM element you want to monitor and the hook will report the status.

import React from 'react'
import { useClickOutside } from 'react-click-outside-hook'

function Component() {
  const [ref, hasClickedOutside] = useClickOutside()
  return <div ref={ref}>{hasClickedOutside.toString()}</div>
}

Keywords

FAQs

Last updated on 11 Apr 2019

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