mirror of
https://github.com/streamich/react-use.git
synced 2026-01-25 14:17:16 +00:00
feat: Add remove method for useList
This commit is contained in:
parent
c75789bf96
commit
5a295d9b46
@ -18,6 +18,10 @@ const useList = <T>(initialList: T[] = []): [T[], Actions<T>] => {
|
||||
entry,
|
||||
...list.slice(index + 1)
|
||||
]),
|
||||
remove: (index) => set([
|
||||
...list.slice(0, index),
|
||||
...list.slice(index + 1)
|
||||
]),
|
||||
push: (entry) => set([...list, entry]),
|
||||
filter: (fn) => set(list.filter(fn)),
|
||||
sort: (fn?) => set([...list].sort(fn)),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user