From c45b9abb5b8e347597c41ad24cb37b1ff5af79a1 Mon Sep 17 00:00:00 2001 From: Justin Walgran Date: Sat, 19 Mar 2022 09:16:29 -0700 Subject: [PATCH] Separate and add deps to FilterSidebarExtendedSearch hooks The original hook generated a lint warning for the missing dependencies. Using a single hook resulted in repeat fetches so we split out a separate hook for each distinct fetch. --- src/app/src/components/FilterSidebarExtendedSearch.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/src/components/FilterSidebarExtendedSearch.jsx b/src/app/src/components/FilterSidebarExtendedSearch.jsx index f05603951..c5d9ce982 100644 --- a/src/app/src/components/FilterSidebarExtendedSearch.jsx +++ b/src/app/src/components/FilterSidebarExtendedSearch.jsx @@ -148,19 +148,25 @@ function FilterSidebarExtendedSearch({ if (!contributorTypeOptions.length) { fetchContributorTypes(); } + }, [contributorTypeOptions, fetchContributorTypes]); + useEffect(() => { if (!facilityProcessingTypeOptions.length) { fetchFacilityProcessingType(); } + }, [facilityProcessingTypeOptions, fetchFacilityProcessingType]); + useEffect(() => { if (!productTypeOptions.length) { fetchProductType(); } + }, [productTypeOptions, fetchProductType]); + useEffect(() => { if (!numberOfWorkersOptions.length) { fetchNumberOfWorkers(); } - }, []); + }, [numberOfWorkersOptions, fetchNumberOfWorkers]); if (fetchingExtendedOptions) { return (