Skip to content

Commit

Permalink
fix(Tree): 修复 autoExpandParent 为 true 时 openKeys 失效问题 #582 (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr-z committed Mar 2, 2022
1 parent f7e6a0c commit 934abc2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react-tree/src/index.tsx
Expand Up @@ -144,18 +144,18 @@ export default function Tree(props: TreeProps) {
const [curSelectedKeys, setCurSelectedKeys] = useState(selectedKeys);

useEffect(() => {
setCurSelectedKeys(props.selectedKeys!);
setCurSelectedKeys(props.selectedKeys || []);
}, [JSON.stringify(props.selectedKeys)]);

// useEffect(() => setCurOpenKeys(openKeys), [openKeys]);
// useEffect(() => setCurSelectedKeys(selectedKeys), [selectedKeys]);

useEffect(() => {
let arrOpenKeys: TreeData['key'][] = [];
let arrOpenKeys: TreeData['key'][] = curOpenKeys;
if (defaultExpandAll) {
arrOpenKeys = getChildKeys(data);
} else if (autoExpandParent) {
arrOpenKeys = getChildKeys(data, undefined, 1);
arrOpenKeys.push(...getChildKeys(data, undefined, 1));
}
setCurOpenKeys(arrOpenKeys);
}, []);
Expand Down

0 comments on commit 934abc2

Please sign in to comment.