How does indefinite-level data render in the form of a tree?

update
found a simple solution in the antd TreeNode component. generates a tree directly from the data . The only thing to consider is the data structure, not the problem of recursion.

you need to render a menu in the form of a tree graph based on an indefinite level of data.
the data structure is as follows:

[{"checked":null,"id":1,"name":"","pId":0},{"checked":null,"id":2,"name":"","pId":3,},{"checked":null,"id":3,"name":"","pId":4},{"checked":null,"id":4,"name":"","pId":5},{"checked":null,"id":5,"name":"","pId":6}]

component is how Antd TreeMenu, is used:

<TreeNode title={} key={}>
   <TreeNode title={} key={}>
   </TreeNode
</TreeNode>

try to solve the problem through recursion . Although I understand the concept, I just don"t have a train of thought. I hope to get an answer!

Apr.11,2021

convert the array into a tree structure first. It is recommended that https://www.npmjs.com/package.

const treeNode = (props) =>
<div className="tree-node">
<div className="tree-node-name">{props.data.name}</div>
{props.data.children ?
<treeNode data={props.data.children}/>
: ''}
</div>

Tree also supports the treeData attribute, as if it were not listed in the document. But the data is translated like this:

[
    key: 'key',
    title: 'your title',
    children: []
]

thanks to the help of @Randal, the final solution is:
adjust the data structure, like this

const treeData = [{
  title: 'Node1',
  value: '0-0',
  key: '0-0',
  children: [{
    title: 'Child Node1',
    value: '0-0-1',
    key: '0-0-1',
  }, {
    title: 'Child Node2',
    value: '0-0-2',
    key: '0-0-2',
  }],
}, {
  title: 'Node2',
  value: '0-1',
  key: '0-1',
}];

use the antd component treeSelect to reference data directly

class Demo extends React.Component {
  state = {
    value: undefined,
  }

  onChange = (value) => {
    console.log(value);
    this.setState({ value });
  }

  render() {
    return (
      <TreeSelect
        style={{ width: 300 }}
        value={this.state.value}
        dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
        treeData={treeData}
        placeholder="Please select"
        treeDefaultExpandAll
        onChange={this.onChange}
      />
    );
  }
}
This is the effect of Demo

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