🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

react-onclickoutside

Package Overview
Dependencies
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-onclickoutside

An onClickOutside wrapper for React components

6.13.2
latest
Source
npm
Version published
Weekly downloads
2.1M
2.72%
Maintainers
2
Weekly downloads
 
Created

What is react-onclickoutside?

The react-onclickoutside npm package is a React component wrapper that provides functionality to detect clicks outside of the component it wraps. It is commonly used to handle scenarios like closing dropdown menus, modals, or any floating elements when a user clicks outside of these components.

What are react-onclickoutside's main functionalities?

Detecting clicks outside a component

This feature allows you to wrap any React component with the react-onclickoutside higher-order component (HOC) to detect and handle clicks outside of it. In the code sample, `MyComponent` is wrapped with `onClickOutside`, enabling it to handle clicks that occur outside of its bounds.

import React, { Component } from 'react';
import onClickOutside from 'react-onclickoutside';

class MyComponent extends Component {
  handleClickOutside = evt => {
    // handle click outside logic here
  };

  render() {
    return <div>My Component</div>;
  }
}

export default onClickOutside(MyComponent);

Other packages similar to react-onclickoutside

Keywords

react

FAQs

Package last updated on 07 Apr 2025

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