🐛 fix(parameterComponent): fix type error in useState declaration for dictArr variable
🐛 fix(parameterComponent): fix logic error in onChange handler to update dictArr state when there are duplicate keys in the array ✨ feat(parameterComponent): add type annotation to onChange handler parameter to improve code clarity
This commit is contained in:
parent
2b2c677f7c
commit
fadd28802d
1 changed files with 8 additions and 4 deletions
|
|
@ -103,7 +103,7 @@ export default function ParameterComponent({
|
||||||
key5: "value5",
|
key5: "value5",
|
||||||
key6: "value6",
|
key6: "value6",
|
||||||
} as {});
|
} as {});
|
||||||
const [dictArr, setDictArr] = useState([]);
|
const [dictArr, setDictArr] = useState([] as string[]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setDictArr(convertObjToArray(dict));
|
setDictArr(convertObjToArray(dict));
|
||||||
|
|
@ -231,10 +231,14 @@ export default function ParameterComponent({
|
||||||
editNode={false}
|
editNode={false}
|
||||||
value={dictArr}
|
value={dictArr}
|
||||||
duplicateKey={errorDuplicateKey}
|
duplicateKey={errorDuplicateKey}
|
||||||
onChange={(newValue) => {
|
onChange={(newValue: string[]) => {
|
||||||
setErrorDuplicateKey(hasDuplicateKeys(newValue));
|
setErrorDuplicateKey(hasDuplicateKeys(newValue));
|
||||||
if(hasDuplicateKeys(newValue)) return;
|
if(hasDuplicateKeys(newValue)){
|
||||||
|
setDictArr(newValue);
|
||||||
|
}
|
||||||
|
else{
|
||||||
setDict(convertArrayToObj(newValue));
|
setDict(convertArrayToObj(newValue));
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue