useSelection
Handle single, multiple, and range selection.
useSelection.tsx
import { useSelection } from "@cermuel/hooks/react";export function useSelectionExample() { const selection = useSelection(['a', 'b', 'c']); return <p>{selection.selected.size} selected</p>;}Props
Param
Type
Default Value
itemsT[]getKey?(item: T) => stringdefaultSelectionKeyReturns
{ selected: Set<string>; toggle: (item: T) => void; clear: () => void; selectAll: () => void; isSelected: (item: T) => boolean; }