Skip to content

useSet ​

A hook that can manage the state of Set.

Code demonstration ​

API ​

typescript
const [
  set,
  {
    add,
    remove,
    reset,
    has,
    clear
  }
] = useSet(initialValue?: Iterable<K>);

Result ​

PropertyDescriptionType
setSet objectReadonly<Ref<Set>>
addAdd item(key: T) => void
removeRemove item(key: T) => void
clearClear Set() => void
hasSet has(key: T) => void
resetReset to default() => void

Params ​

PropertyDescriptionTypeDefault
initialValueOptional, set default valueIterable<K>-

Source ​

Source · Document · Demo

Released under the MIT License.