🐛 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",
|
||||
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));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue