
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-hook-selection
Advanced tools
A React hook for accessing user selection.
Using npm:
npm install --save react-hook-selection
Using yarn:
yarn add react-hook-selection
import React from 'react'
import useScreenOrientation from 'react-hook-selection'
const ComponentWithSelection = () => {
const selection = useSelection()
return (
<Fragment>
<p style={{userSelect: 'none'}}>
Selection is: {JSON.stringify(selection)}
</p>
<p>Integer faucibus nec risus a ornare. Lorem ipsum <strong> dolor sit amet</strong>, consectetur adipiscing elit. Donec et purus sit amet lacus vulputate ultricies. Donec tincidunt, urna vitae sollicitudin mattis, erat massa placerat lorem, ut pharetra nulla dolor ullamcorper felis. Suspendisse id lectus sit amet <a href="https://npmjs.com">dolor egestas rhoncus</a> id non dui. Pellentesque sed rhoncus turpis, sed efficitur lacus. Aliquam erat volutpat. Morbi ornare pulvinar libero vitae maximus. Aliquam erat volutpat. Nam consequat augue vel eros tincidunt aliquam. In sodales pretium pulvinar. Donec in hendrerit urna. Mauris pharetra diam at justo porta viverra. Sed ipsum mauris, imperdiet et turpis sed, suscipit vestibulum neque. Sed auctor tortor vitae tellus feugiat, sit amet tincidunt lectus ultrices.</p>
</Fragment>
)
}
If you interpolate user selection directly in JSX, in order to avoid the browser potentially going absolutely bananas, make sure that the element that renders the selection as its content has user selection disabled, just like in the usage example above.
Selection value is only accessible in plain text format. So even if the user has selected multiple elements with complex structure and rich formatting, this hook will only be able to provide you with the text content of the selected elements.
Contributions are welcome. File bug reports, create pull requests, feel free to reach out at tothab@gmail.com.
LGPL-3.0
FAQs
React hook for accessing user selection
We found that react-hook-selection 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.