Skip to content

Commit

Permalink
fix: if문 setTimeout 안으로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
xodms0309 committed Sep 15, 2023
1 parent e8441fe commit c409ee1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frontend/src/hooks/common/useScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const useScroll = () => {
};

const scrollToPosition = <T extends HTMLElement>(ref: RefObject<T>) => {
if (ref.current) {
const timeout = setTimeout(() => {
ref.current?.scrollIntoView({ behavior: 'smooth' });
const timeout = setTimeout(() => {
if (ref.current) {
ref.current.scrollIntoView({ behavior: 'smooth' });
clearTimeout(timeout);
}, 100);
}
}
}, 100);
};

return { scrollToTop, scrollToPosition };
Expand Down

0 comments on commit c409ee1

Please sign in to comment.