From c5c0f8f6ca11f61ef8796d4b4e9e93c75c25455c Mon Sep 17 00:00:00 2001 From: lazybonee <1119357381@qq.com> Date: Thu, 14 Dec 2023 20:05:55 +0800 Subject: [PATCH] fix(table): change setTimeout to window.requestAnimationFrame in updateExpandOnDataChange function (#2668) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化异步获取树形数据的函数 --- src/table/hooks/useTreeDataExpand.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/table/hooks/useTreeDataExpand.ts b/src/table/hooks/useTreeDataExpand.ts index b530b8c25b..ca82767c7c 100644 --- a/src/table/hooks/useTreeDataExpand.ts +++ b/src/table/hooks/useTreeDataExpand.ts @@ -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]); });