Skip to content

Commit

Permalink
perf(tree): inherit props status while changing the data
Browse files Browse the repository at this point in the history
"fix #1140"
  • Loading branch information
CodingOnStar committed Jul 25, 2022
1 parent 51055e5 commit 9ef9525
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tree/useStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,14 @@ export function useStore(props: TdTreeProps, refresh: () => void): TreeStore {

useUpdateEffect(() => {
if (data && Array.isArray(data)) {
const expanded = store.getExpanded();
const checked = store.getChecked();
const actived = store.getActived();
store.removeAll();
store.append(data);
store.setChecked(checked);
store.setActived(actived);
store.setExpanded(expanded);
}
}, [data, store]);

Expand Down

0 comments on commit 9ef9525

Please sign in to comment.