useSet
A hook that can manage the state of Set.
Overview
A hook that can manage the state of Set.
Installation
Open inpnpm dlx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useSet.jsonnpx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useSet.jsonyarn shadcn@latest add https://shadcn-ahooks.vercel.app/r/useSet.jsonbun shadcn@latest add https://shadcn-ahooks.vercel.app/r/useSet.jsonA hook that can manage the state of Set.
Examples
Default usage
API
const [
set,
{
add,
remove,
reset
}
] = useSet<K>(initialValue);Result
| Property | Description | Type |
|---|---|---|
| set | Set object | Set<K> |
| add | Add item | (key: K) => void |
| remove | Remove item | (key: K) => void |
| reset | Reset to default | () => void |
Params
| Property | Description | Type | Default |
|---|---|---|---|
| initialValue | Optional, set default value | Iterable<K> | - |