Skip to content

Commit

Permalink
Merge pull request #111 from TheSharpieOne/patch-1
Browse files Browse the repository at this point in the history
feat: Add remove method for useList
  • Loading branch information
streamich authored Feb 21, 2019
2 parents c75789b + 5a295d9 commit 094769c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/useList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 094769c

Please sign in to comment.