The problem is you are updating the state using old setState syntax. Like this,
setState({ stateKey: stateValue });
But new useState hook doesn't need the stateKey. You can update the state by just calling the setState(stateValue)
.
So, instead of writing this,
settreeData({
treeData: removeNodeAtPath({
treeData: treeData,
path: path,
getNodeKey: ({ treeIndex: number, node: TreeNode }) => {
return number;
},
ignoreCollapsed: false
})
});
You should write this,
settreeData(
removeNodeAtPath({
treeData: treeData,
path: path,
getNodeKey: ({ treeIndex: number, node: TreeNode }) => {
return number;
},
ignoreCollapsed: false
})
);
Here is the working code link.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…