import React, { useState, useEffect, useContext, useRef, memo } from 'react'; // import { Tree } from 'antd'; // const { TreeNode } = Tree; import Tree, { TreeNode } from 'rc-tree'; import 'rc-tree/assets/index.css'; const $ = window.$; export default function RepoTree(props) { const { fileTreeData, onLoadData, onTreeSelect, fileTreeSelectedKeys, loadRepoFiles } = props; const [expandedKeys, setExpandedKeys] = useState([]) useEffect(() => { loadRepoFiles() }, []) if (!fileTreeData || fileTreeData.length === 0) { return "" } const onExpand = (expandedKeys) => { // console.log('onExpand', arguments); // if not set autoExpandParent to false, if children expanded, parent can not collapse. // or, you can remove all expanded children keys. setExpandedKeys(expandedKeys) } const loop = (data) => { return data.map((item) => { if (item.children) { return {loop(item.children)}; } return ( ); }); }; const treeNodes = loop(fileTreeData); // selectable={false} return ( {treeNodes} ) }