From fadd28802d9dcad2a46e9f22a5ed295e4eb1091a Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Thu, 31 Aug 2023 10:36:49 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(parameterComponent):=20fix?= =?UTF-8?q?=20type=20error=20in=20useState=20declaration=20for=20dictArr?= =?UTF-8?q?=20variable=20=F0=9F=90=9B=20fix(parameterComponent):=20fix=20l?= =?UTF-8?q?ogic=20error=20in=20onChange=20handler=20to=20update=20dictArr?= =?UTF-8?q?=20state=20when=20there=20are=20duplicate=20keys=20in=20the=20a?= =?UTF-8?q?rray=20=E2=9C=A8=20feat(parameterComponent):=20add=20type=20ann?= =?UTF-8?q?otation=20to=20onChange=20handler=20parameter=20to=20improve=20?= =?UTF-8?q?code=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/parameterComponent/index.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 33073b628..b06271782 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -103,7 +103,7 @@ export default function ParameterComponent({ key5: "value5", key6: "value6", } as {}); - const [dictArr, setDictArr] = useState([]); + const [dictArr, setDictArr] = useState([] as string[]); useEffect(() => { setDictArr(convertObjToArray(dict)); @@ -231,10 +231,14 @@ export default function ParameterComponent({ editNode={false} value={dictArr} duplicateKey={errorDuplicateKey} - onChange={(newValue) => { + onChange={(newValue: string[]) => { setErrorDuplicateKey(hasDuplicateKeys(newValue)); - if(hasDuplicateKeys(newValue)) return; - setDict(convertArrayToObj(newValue)); + if(hasDuplicateKeys(newValue)){ + setDictArr(newValue); + } + else{ + setDict(convertArrayToObj(newValue)); + } }} />