Antd tree clears the selected treenode

For the tree component under

antd form, after one of the treenode is selected, close the window and open it again. The previously selected treenode is still selected. How can I empty the selected treenode? Thank you!

<div>
   <h4></h4>
        <Tree className="rolesTree"
            checkable
            onCheck={this.onCheck}
            defaultExpandAll={true}
            loadData={this.onLoadData}
         >
          {this.renderTreeNodes(roles)}
        </Tree>
</div>

Mar.05,2021

didn't you change the state to re-render the page when you close the window?


problems like this should immediately come to mind controlled and uncontrolled components.
so you can modify the Tree to be subject to recent components.


state = {
checkedKeys:[]
}

in the form tree component

<Tree className="rolesTree"
      checkable
      onCheck={this.onCheck}
      checkedKeys={checkedKeys}
      defaultExpandAll={true}
      loadData={this.onLoadData}
    >
      {this.renderTreeNodes(roles)}
    </Tree>

that's how it's solved. I am not familiar with react and antd, just now, so I am learning to do it now. Thank you

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-1eaa121-1faa.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-1eaa121-1faa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?