From 7d91c144810b22a53af90d5358f7fa9f0756375e Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Sat, 22 Jul 2023 09:05:04 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(inputListComponent):=20remov?= =?UTF-8?q?e=20redundant=20useEffect=20that=20sets=20inputList=20value=20f?= =?UTF-8?q?rom=20props=20=F0=9F=90=9B=20fix(inputListComponent):=20fix=20c?= =?UTF-8?q?loning=20of=20inputList=20array=20in=20onChange=20event=20handl?= =?UTF-8?q?er=20to=20prevent=20mutation=20of=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/components/inputListComponent/index.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/frontend/src/components/inputListComponent/index.tsx b/src/frontend/src/components/inputListComponent/index.tsx index a54b4151f..7a691f74c 100644 --- a/src/frontend/src/components/inputListComponent/index.tsx +++ b/src/frontend/src/components/inputListComponent/index.tsx @@ -13,12 +13,6 @@ export default function InputListComponent({ }: InputListComponentType) { const [inputList, setInputList] = useState(value ?? [""]); - useEffect(() => { - if (value) { - setInputList(value); - } - }, [value]); - useEffect(() => { if (disabled) { setInputList([""]); @@ -48,7 +42,7 @@ export default function InputListComponent({ placeholder="Type something..." onChange={(e) => { setInputList((old) => { - let newInputList = _.cloneDeep(old); + let newInputList = _.cloneDeep(inputList); newInputList[idx] = e.target.value; return newInputList; });