State Management
useSetState
About
Manage the state of a Set in React. Exposes add, delete and clear methods along with the current set to easily manipulate values in a set.
Examples
Basic example with numbers
Working with strings and membership checking
Managing selected items
Arguments
| Argument value | Type | Description | Default | 
|---|---|---|---|
| initialSetValue | Set<T> | The initial value of the set to manage | Required | 
Returns
Returns an array with two elements:
| Return value | Type | Description | Default | 
|---|---|---|---|
| set | Set<T> | The current state of the Set | new Set() | 
| controls | UseSetStateControls<T> | An object containing set manipulation methods | 
Control Methods
| Method | Type | Description | 
|---|---|---|
| add | Function | Add one or more values to the set | 
| delete | Function | Delete one or more values from the set | 
| clear | Function | Remove all values from the set |