我正在使用delete
来尝试删除数组上的项目;
const handleRowDeletion = index => {
const inputsAdded = shareStructureInputs;
const inputs = startupFourthStepForm.shares_estructure;
delete inputs[index];
delete inputsAdded[index];
}
我可以看到第一个数组inputsAdded
在正确的索引处被删除,但是第二个数组inputs
没有被删除。
这是inputsAdded
返回的内容:
[
"share-structure-input-0",
"share-structure-input-1",
"share-structure-input-2"
]
还有inputs
:
[
{
"name": "Name 1",
"percentage": 10
},
{
"name": "Name 2",
"percentage": 10
},
{
"name": "Name 3",
"percentage": 80
}
]
然后我在map
<Button onClick={() => handleRowDeletion(index)}>
- Delete Row
</Button>