From 5a295d9b464aa2b06fbb7d67f0fd9e5910ed5cae Mon Sep 17 00:00:00 2001 From: Evan Sharp Date: Thu, 21 Feb 2019 14:06:37 -0500 Subject: [PATCH] feat: Add remove method for useList --- src/useList.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/useList.ts b/src/useList.ts index 46b4e0a42c..6658a3c0a2 100644 --- a/src/useList.ts +++ b/src/useList.ts @@ -18,6 +18,10 @@ const useList = (initialList: T[] = []): [T[], Actions] => { 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)),