Skip to content

Commit

Permalink
perf(tabs): 添加clearTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
epoll-j committed Sep 11, 2024
1 parent 9d07c2f commit f1428a2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ const Tabs: FC<TabsProps> = (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
}, []);
Expand Down

0 comments on commit f1428a2

Please sign in to comment.