Skip to content

Commit

Permalink
feat: Add remove method for useList
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSharpieOne authored Feb 21, 2019
1 parent c75789b commit 5a295d9
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 5a295d9

Please sign in to comment.