Usage
use-list-state hook provides an API to work with list state:
API
use-list-state takes array as single argument and returns list values and handlers to change them in tuple, similar to react use-state hook.
Hook provides handlers to work with array data:
append
– add items to the end of the listprepend
– add items to the start of the listpop
– remove last itemshift
– remove first iteminsert
– insert items at given indexremove
– remove items at given indicesreorder
– move item from one position to anotherapply
– apply given function to all items in the listapplyWhere
- apply given function to selective items using conditionsetItem
– replace item at given indexsetItemProp
– set item property at given indexsetState
– set list state with react action
Indeterminate state checkbox example
TypeScript
Definition
Set item type
By default use-list-state will use type from initialValues. If you init hook with empty array, you must specify item type:
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback