Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-selection-hooks
Advanced tools
Readme
Our operating systems use click modifiers to make our lives easier when selecting things and so should our react apps! This project aims to build abstractions around managing a selection of items from an array.
yarn add react-selection-hooks
npm install --save react-selection-hooks
"react": "^17.0.2", "react-dom": "^17.0.2"
https://ssteuteville.github.io/react-selection-hooks/
import React from 'react';
import useSelection from 'react-selection-hooks';
const items = Array.from({ length: 10 })
.map((_, i) => ({ key: `Key ${i}` }));
// for best performance this should be memoized or const
const getKey = item => item.key;
const MyComponent: React.FC = () => {
const {
// an array of selected items
selectedItems,
// the number of items selected
selectionCount,
// add one item to the selection
appendSelection,
// remove all items from selection
clearSelection,
// check if item is selected
isSelected,
// (item, mouseEvent) => void, mouse event handler with modifier support
onSelect,
// remove one item from selection
removeFromSelection,
// toggle whether an item is selected or not
toggleSelection,
// the ...other properites would be determined by the reducer
// passed into the optional reducer prop
state: { selectedItems, ...other },
// useSelection has optional `reducer` and `defaultState` parameters
} = useSelection(items, { getKey });
return (
<ul>
{
items.map(item => (
<li
key={item.key}
onClick={e => onSelect(item, e)}
style={{ border: isSelected(item) ? '1px solid blue' : undefined }}
>
{item.key}
</li>
)
}
</ul>
)
}
Currently just asking for ideas for a long-term api and opinions on usefulness/interest
Use this issue if you're interested: https://github.com/ssteuteville/react-selection-hooks/issues/1
FAQs
Our operating systems use click modifiers to make our lives easier when selecting things and so should our react apps! This project aims to build abstractions around managing a selection of items from an array.
The npm package react-selection-hooks receives a total of 14 weekly downloads. As such, react-selection-hooks popularity was classified as not popular.
We found that react-selection-hooks demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.