From 6064d726cedcf87c60e3a021d7e1981f303c85b1 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 19 Jan 2023 07:25:19 -0800 Subject: [PATCH] Fix infinite loop in SelectWithSelect --- components/SelectWithSelect/index.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/SelectWithSelect/index.tsx b/components/SelectWithSelect/index.tsx index 31edd284..ac4ff6a4 100644 --- a/components/SelectWithSelect/index.tsx +++ b/components/SelectWithSelect/index.tsx @@ -50,6 +50,7 @@ const SelectWithInput = ({ const [currentItemValue, setCurrentItemValue] = useState(rightSelectValue) // Hooks + // if (currentItemSkill) sendValues(currentItemSkill.id, currentItemValue) // Set default values from props useEffect(() => { @@ -57,10 +58,6 @@ const SelectWithInput = ({ setCurrentItemValue(rightSelectValue) }, [leftSelectValue, rightSelectValue]) - useEffect(() => { - if (currentItemSkill) sendValues(currentItemSkill.id, currentItemValue) - }, [currentItemSkill, currentItemValue]) - // Methods: UI state management function changeOpen(side: 'left' | 'right') { if (side === 'left' && !leftSelectDisabled) { @@ -120,6 +117,7 @@ const SelectWithInput = ({ function handleRightSelectChange(rawValue: string) { const value = parseFloat(rawValue) setCurrentItemValue(value) + if (currentItemSkill) sendValues(currentItemSkill.id, value) } return (