tree icon indicating copy to clipboard operation
tree copied to clipboard

`children` of Tree is deprecated. Please use `treeData` instead.

Open OldKinn opened this issue 5 years ago • 8 comments

<Tree className="file-tree" expandedKeys={expandedKeys} selectedKeys={selectedKeys} onSelect={this.handleClick} onExpand={this.handleExpand} > {files.map(createNode)} </Tree> 我需要自定义TreeNode的title,使用这种模式会出现上面的警告信息 [email protected]

OldKinn avatar Sep 05 '20 00:09 OldKinn

+1 Getting the same issue. Warning: 'children' of Tree is deprecated. Please use 'treeData' instead.

gowda-nirmal avatar Sep 07 '20 06:09 gowda-nirmal

Same issue here with same version as OP

Jared-Dahlke avatar Sep 10 '20 21:09 Jared-Dahlke

Just use the TreeData prop in the Tree component instead of children. image

Glazzy avatar Sep 22 '20 07:09 Glazzy

But I am getting this warning when doing controlled version:

` <Tree
              showIcon={false}
              showLine={false}
              switcherIcon={<Folder/>}
              checkable
              onExpand={this.onExpand}
              expandedKeys={expandedKeys}
              autoExpandParent={autoExpandParent}
              onCheck={this.onCheck}
              checkedKeys={this.state.checkedKeys}
              onSelect={this.onSelect}
              selectedKeys={this.state.selectedKeys}
              filterTreeNode={this.filterTreeNode}
            >
             
 {loop(this.props.data)}
            
</Tree>`



`const loop = data =>
      data.map(item => {
        if (this.filterKeys && this.filterFn(item.key)) {
          this.filterKeys.push(item.key)
        }
        if (item.children) {
          return (
            <TreeNode style={{fontFamily: defaultFont.fontFamily, fontWeight: defaultFont.fontWeight, lineHeight: defaultFont.lineHeight}} key={item.key} title={item.title} disableCheckbox={item.key === 'mydisabledkey'}>
              {loop(item.children)}
            </TreeNode>
          )
        }
        return <TreeNode  style={{fontFamily: defaultFont.fontFamily, fontWeight: defaultFont.fontWeight, lineHeight: defaultFont.lineHeight}} key={item.key} title={item.title} />
      })`

Jared-Dahlke avatar Sep 23 '20 15:09 Jared-Dahlke

I'm having the same issue. I would like to customize <TreeNode />.

svetlanapuro avatar Oct 15 '20 06:10 svetlanapuro

Found a solution to my problem. If you want to customize the title in Ant Design, you can do it with titleRender.

svetlanapuro avatar Oct 15 '20 21:10 svetlanapuro

Hi, What is the state of this issue? Is there a plan to revert deprecation for children property?

gcattan avatar Apr 01 '22 09:04 gcattan

@Jared-Dahlke

` <Tree showIcon={false} showLine={false} switcherIcon={<Folder/>} checkable onExpand={this.onExpand} expandedKeys={expandedKeys} autoExpandParent={autoExpandParent} onCheck={this.onCheck} checkedKeys={this.state.checkedKeys} onSelect={this.onSelect} selectedKeys={this.state.selectedKeys} filterTreeNode={this.filterTreeNode} >

Does filterTreeNode work in your sample? It gets called in my case but all items (that should be invisible) are still visible.

AHorak avatar Jan 30 '23 10:01 AHorak