From f1428a25ef00492934874b9d9d3b0c72d5d1f59c Mon Sep 17 00:00:00 2001 From: epoll-j Date: Wed, 11 Sep 2024 15:08:59 +0800 Subject: [PATCH] =?UTF-8?q?perf(tabs):=20=E6=B7=BB=E5=8A=A0clearTimeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tabs/Tabs.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tabs/Tabs.tsx b/src/tabs/Tabs.tsx index 2fdd5af7..aa83caee 100644 --- a/src/tabs/Tabs.tsx +++ b/src/tabs/Tabs.tsx @@ -186,12 +186,13 @@ const Tabs: FC = (props) => { useEffect(() => { window.addEventListener('resize', moveToActiveTab, false); - setTimeout(() => { + const timeout = setTimeout(() => { moveToActiveTab(); }, 300); return () => { window.removeEventListener('resize', moveToActiveTab); + clearTimeout(timeout); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []);