diff --git a/code/frontend/src/hooks/useArrayState.js b/code/frontend/src/hooks/useArrayState.js index a0d312e..d8b895a 100644 --- a/code/frontend/src/hooks/useArrayState.js +++ b/code/frontend/src/hooks/useArrayState.js @@ -10,10 +10,10 @@ export default function useArrayState(def) { oldArray => [...oldArray, newSingle] ) }, - [value, setValue] + [] ) - const removeValue = useCallback( + const spliceValue = useCallback( position => { setValue( oldArray => { @@ -22,8 +22,18 @@ export default function useArrayState(def) { return oldArray } ) - } + }, + [] ) - return {value, setValue, appendValue, removeValue} + const removeValue = useCallback( + remValue => { + setValue( + oldArray => oldArray.filter(item => item !== remValue) + ) + }, + [] + ) + + return {value, setValue, appendValue, spliceValue, removeValue} } \ No newline at end of file diff --git a/code/frontend/src/hooks/useData.js b/code/frontend/src/hooks/useData.js index a729653..d440b65 100644 --- a/code/frontend/src/hooks/useData.js +++ b/code/frontend/src/hooks/useData.js @@ -35,7 +35,7 @@ export default function useData(fetchData, method, path, body, init) { setLoading(false) } }, - [fetchData, method, path, body, init, setData, setError, setLoading] + [fetchData, method, path, body, init] ) /** @@ -51,7 +51,7 @@ export default function useData(fetchData, method, path, body, init) { await load() }, - [load, setData, setError] + [load] ) useEffect( diff --git a/code/frontend/src/hooks/useLocalStorageState.js b/code/frontend/src/hooks/useLocalStorageState.js index 4734666..f53c868 100644 --- a/code/frontend/src/hooks/useLocalStorageState.js +++ b/code/frontend/src/hooks/useLocalStorageState.js @@ -54,7 +54,7 @@ export default function useLocalStorageState(key, def) { setValue(value) save(value) }, - [setValue, save] + [save] ) return [value, setAndSave]