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

NameTypeDescriptionDefault
initialValueT[]Initial array.[]

Returns

NameDescription
valueCurrent array.
actionsMethods: 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.
Saha UI - The Modern React Component Library