From 2ac843696f426ecf56fae1fc52bb9be4efb1ffd3 Mon Sep 17 00:00:00 2001 From: Yury Saukou Date: Tue, 12 Nov 2024 18:11:34 +0400 Subject: [PATCH] revert changes in useFilters hook --- lib/AcqList/hooks/useFilters.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/AcqList/hooks/useFilters.js b/lib/AcqList/hooks/useFilters.js index e266baa5..ce6f6160 100644 --- a/lib/AcqList/hooks/useFilters.js +++ b/lib/AcqList/hooks/useFilters.js @@ -22,7 +22,7 @@ const useFilters = (resetData, initialFilters = INITIAL_FILTERS, options = OPTIO const applyFilters = useCallback( (type, value) => { - const newFilters = {}; + const newFilters = { ...filters }; if (Array.isArray(value) && value.length === 0) { newFilters[type] = undefined; @@ -30,16 +30,13 @@ const useFilters = (resetData, initialFilters = INITIAL_FILTERS, options = OPTIO newFilters[type] = value; } - setFilters((currentFilters) => ({ - ...currentFilters, - ...newFilters, - })); + setFilters(newFilters); resetData(); return newFilters; }, - [resetData], + [filters, resetData], ); const applySearch = useCallback(