Launch Week Day 5: Introducing Reachability for PHP.Learn More →
Socket
Book a DemoSign in
Socket

@glennreyes/react-click-outside

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glennreyes/react-click-outside

🐭 Handles clicks outside of a component

latest
Source
npmnpm
Version
0.1.0-alpha.0
Version published
Maintainers
1
Created
Source

React ClickOutside

🐭 Handles clicks outside of a component.

Installation

yarn add @glennreyes/react-click-outside

Usage

Simple example

<ClickOutside onClickOutside={() => closeMenu()}>
  <Menu />
</ClickOutside>

This will wrap the children with a div container.

Custom container

To use a custom container, you can use the component with a render prop:

<ClickOutside onClickOutside={() => closeMenu()}>
  {({ containerRef }) => <Menu innerRef={containerRef} />}
</ClickOutside>

To just discard the div container, you can do following:

<ClickOutside onClickOutside={() => closeMenu()}>
  {() => <Menu />}
</ClickOutside>

Inspired by

  • tj/react-click-outside

License

MIT

Keywords

onclick

FAQs

Package last updated on 15 Oct 2018

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