Skip to content

useSet

Category
Export Size
247 B
Last Changed
5 days ago

A real Set whose mutations re-render.

Demo

Usage

tsx
import { 
useSet
} from '@reause/shared'
const
set
=
useSet
(['a'])
set
.
add
('b') // re-renders; returns the same Set
set
.
has
('b') // true
set
.
size
// 2
set
.
delete
('a') // re-renders; returns true
set
.
clear
() // re-renders; returns undefined

Type Declarations

ts
export function useSet<T = any>(values?: readonly T[] | null): Set<T>

Source

Source · Demo · react-hookz

Contributors

hairyf

Changelog

v0.1.6 on
a099a - feat(shared): add useSet (#933)

Released under the MIT License. v0.1.8