
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
use-outside-click-react-hook
Advanced tools
React Hook for Handling Clicks and Touches Outside a Specified Element
React Hook for Handling Clicks and Touches Outside a Specified Element (Only 3 code steps!).
Storybook:
https://shadiabuhilal.github.io/use-outside-click-react-hook/
npm i use-outside-click-react-hook
import useOutsideClick from 'use-outside-click-react-hook';
useOutsideClick React Hook
Example:
const [currentStepIndexState, setCurrentStepIndex] = useState(0);
...
export default function FooComponent() {
const [isOpenState, setIsOpenState] = useState(false);
// STEP1: Use ref to attach this functionality to the element that requires outside click and touch detection.
const menuPopupDivRef = useRef(null);
// STEP2: Use useOutsideClick React Hook to apply this functionality to the element that requires outside click and touch detection.
useOutsideClick(menuPopupDivRef, () => {
setIsOpenState(false);
});
return <div className='page-content'>
<button data-testid="btnMenu" onClick={()=> setIsOpenState(true)}>Menu</button>
{/* STEP3: Set ref to the element that requires outside click and touch detection */}
{isOpenState && <div ref={menuPopupDivRef} className='menu-popup'>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>}
</div>;
}
For more info, please check storybook
FAQs
React Hook for Handling Clicks and Touches Outside a Specified Element
The npm package use-outside-click-react-hook receives a total of 11 weekly downloads. As such, use-outside-click-react-hook popularity was classified as not popular.
We found that use-outside-click-react-hook 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.