Installations
npm install react-outer-click
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
17.8.0
NPM Version
8.6.0
Score
66.4
Supply Chain
90.3
Quality
75.8
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (99.24%)
Shell (0.76%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
108,118
Last Day
105
Last Week
408
Last Month
1,816
Last Year
25,778
GitHub Statistics
MIT License
5 Stars
174 Commits
2 Forks
1 Watchers
4 Branches
1 Contributors
Updated on Apr 25, 2022
Bundle Size
2.87 kB
Minified
1.26 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.8.0
Package Id
react-outer-click@3.8.0
Unpacked Size
25.17 kB
Size
5.70 kB
File Count
7
NPM Version
8.6.0
Node Version
17.8.0
Total Downloads
Cumulative downloads
Total Downloads
108,118
Last Day
81%
105
Compared to previous day
Last Week
-15%
408
Compared to previous week
Last Month
27.2%
1,816
Compared to previous month
Last Year
-18%
25,778
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Peer Dependencies
1
Dev Dependencies
22
react-outer-click
React component and hook which detect mouse clicks outside of an element.
Usage
useOuterClick
Hook (recommended)
1useOuterClick(refs, handler);
Parameters
refs
a single ref or array of refs to not be handled the user has clickedhandler
callback function to be called when the user has clicked
Example
1import { useOuterClick } from 'react-outer-click'; 2 3const Example = (props) => { 4 const el = useRef(null); 5 6 useOuterClick(el, (event) => { 7 event.preventDefault(); 8 console.log('Clicked outside'); 9 }); 10 11 return <div ref={el}>Example</div>; 12};
OuterClick
Component
1<OuterClick onOuterClick={}></OuterClick>
Props
children
elements that will not be handled when clickedonOuterClick
callback function to be called when the user has clicked
Example
1import { OuterClick } from 'react-outer-click'; 2 3const Example = (props) => { 4 return ( 5 <OuterClick 6 onOuterClick={() => { 7 event.preventDefault(); 8 console.log('Clicked outside'); 9 }} 10 > 11 Example 12 </OuterClick> 13 ); 14};
:warning: Previous versions of react-outer-click allowed
OuterClick
to be imported as default export. This is no longer supported and has been removed.
:information_source: The OuterClick
component will wrap your children with a <div>
element, and any additional props will be passed down. You can change the element rendered with the as
prop:
1 ... 2 <OuterClick as="span" onOuterClick={...}> 3 Example 4 </OuterClick> 5 ...
Requirements
Requires a minimum of React version 16.8.0. If you're on an older version of React, then checkout v1.

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Score
3
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More