我正在尝试从创建的树中删除节点。为此,我从节点组件中调用删除节点,该组件在下面调用函数“ deleteNode”:
private searchTree(treeNode: JSX.Element, rootNode: JSX.Element) {
return (
// delete node here but other function does not get here
console.log('here);
)
}
private deleteNode(conditionOperator: string, variable: string, value: string) {
return () => {
console.log(conditionOperator + variable + value);
const treeNodeToRemove: JSX.Element = <TreeNode
operator={''}
conditionOperator={conditionOperator}
variable={variable}
value={value}
childNode={null}
result={null}
/>
console.log('here1');
return this.searchTree(treeNodeToRemove, this.rootNode)
}
}
private rootNode: JSX.Element = (
<TreeNode
operator={'if'}
conditionOperator={'EQUALS'}
variable={'region'}
value={this.props.region}
result={null}
childNode={null}
isInEditingMode={true}
isRootNode={true}
deleteNode={this.deleteNode}
/>
);
应该使用searchTree函数以递归方式搜索所需的节点以将其删除。但是,我什至从未接触过console.log('here')语句。我是JS新手,不确定我的函数调用是否正确。我已经在构造函数中绑定了这两个函数。