
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
react-click-outside
Advanced tools
Enhance a React component with a Higher Order Component that provides click outside detection.
Note: React 0.14 required for version >= 2.x. This assumes react
and
react-dom
is installed in your project. Continue using version 1.x for React
0.13 support.
Installation:
npm install react-click-outside
Some component that you wish to enhance with click outside detection:
const enhanceWithClickOutside = require('react-click-outside');
const React = require('react');
const Dropdown = React.createClass({
getInitialState() {
return {
isOpened: false,
};
},
handleClickOutside() {
this.setState({ isOpened: false });
},
render() {
...
},
});
module.exports = enhanceWithClickOutside(Dropdown);
The enhanceWithClickOutside
function wraps the provided component in another
component that registers a click handler on document
for the event capturing
phase. Using the event capturing phase prevents elements with a click handler
that calls stopPropagation
from cancelling the click event that would
eventually trigger the component's handleClickOutside
function.
There are some mixins that provide click outside detection functionality, but
they prevent the component from implementing the componentDidMount
and
componentWillUnmount
life cycle hooks. I recommend not using a mixin for this
case.
FAQs
A component wrapper that provides click outside detection.
The npm package react-click-outside receives a total of 55,650 weekly downloads. As such, react-click-outside popularity was classified as popular.
We found that react-click-outside demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.