State Management
useArray
Manage array state with helper methods for push, pop, filter, update, and more.
import { useArray } from "saha-ui"Uses
State helper for arrays with common mutation helpers (add/push/remove/clear/update/filter/set).
Props
| Name | Type | Description | Default |
|---|---|---|---|
| initialValue | T[] | Initial array. | [] |
Returns
| Name | Description |
|---|---|
| value | Current array. |
| actions | Methods: setValue, add, push, removeByIndex, removeById, clear, updateByIndex, updateById, filter, set. |
Example
const [items, { add, removeByIndex, clear }] = useArray([]); add({ id: 1 }); removeByIndex(0); clear();Notes
Helpers are memoized and provide an immutable-friendly API for list updates.