Skip to content

Commit

Permalink
fix(table): change setTimeout to window.requestAnimationFrame in upda…
Browse files Browse the repository at this point in the history
…teExpandOnDataChange function (#2668)

优化异步获取树形数据的函数
  • Loading branch information
lazybonee authored and NWYLZW committed Jan 11, 2024
1 parent 5de2cc5 commit c5c0f8f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/table/hooks/useTreeDataExpand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ export function useTreeDataExpand(
expandAll('default-expand-all', [...data]);
setIsDefaultExpandAllExecute(true);
} else if (tExpandedTreeNode?.length) {
setTimeout(() => {
const asyncCall = typeof window !== 'undefined' ? window.requestAnimationFrame : setTimeout;
asyncCall(() => {
const newData = updateExpandState([...data], tExpandedTreeNode, []);
setDataSource([...newData]);
});
Expand Down

0 comments on commit c5c0f8f

Please sign in to comment.