From 78b1b76889c77271906b3816e3db3f3fa48414bf Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 19 Oct 2023 09:24:30 +0200 Subject: [PATCH] :bug: [#546] Fix cascade of requests firing Hook dependencies operate on the identity, and the identity of the selectedProducts changes every time on each render, while the contents stay the same. JSON.stringify is the recommended approach to mitigate using non-primivites in hook dependency arrays. Note that the caching masked the issue partially - it caused the request cascade to stop, but the problem still showed with multi- product appointments. Backport-of: #569 --- src/components/appointments/ProductSelect.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/appointments/ProductSelect.js b/src/components/appointments/ProductSelect.js index ac9f90d35..b5325edc4 100644 --- a/src/components/appointments/ProductSelect.js +++ b/src/components/appointments/ProductSelect.js @@ -56,7 +56,8 @@ const ProductSelect = ({name, selectedProducts}) => { const {value} = getFieldProps(name); const getOptions = useCallback( async () => await getProducts(baseUrl, selectedProducts, value), - [baseUrl, selectedProducts, value] + // eslint-disable-next-line react-hooks/exhaustive-deps + [baseUrl, JSON.stringify(selectedProducts), value] ); return (