Antd tree defaultExpandAll problem

when antd tree sets defaultExpandAll to true, it expands by default the first time it is initialized. When the tree is collapsed, the window is closed and the window is opened again, the tree remains collapsed. Then I use expandedKeys to control the nodes that need to be expanded, but clicking on the nodes set by expandedKeys cannot be collapsed. May I ask how to solve the appeal problem? Thank you!

 <Tree
    checkable
    onCheck={this.onCheck}
    defaultExpandAll={expandAllState}
    checkedKeys={checkedkey}
    loadData={this.onLoadData}
    expandedKeys={expandedKeys}
  >
   {this.renderTreeNodes(roles)}
  </Tree>
Mar.06,2021

https://github.com/ant-design. look here, this is the best solution


after you set expandedKeys , the Tree component becomes a controlled component.
when you open the window again, you need to set expandedKeys to open it all.
in addition, the defaultExpandAll attribute is loaded only when the component is rendered first, and this value no longer works when it is mount.


you need to write an OnTreeExpand method to change his key value

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e874d6-46c00.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e874d6-46c00.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?