feat: Add remove method for useList

This commit is contained in:
Evan Sharp 2019-02-21 14:06:37 -05:00 committed by GitHub
parent c75789bf96
commit 5a295d9b46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)),