Skip to content

Commit

Permalink
fix: [QuickReplies] clearTimeout after unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
akai committed Jun 30, 2021
1 parent 6062d19 commit 1602f33
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/QuickReplies/QuickReplies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ const QuickReplies = (props: QuickRepliesProps) => {
const [scrollEvent, setScrollEvent] = useState(!!onScroll);

useLayoutEffect(() => {
let timer: ReturnType<typeof setTimeout>;

if (scroller.current) {
setScrollEvent(false);
scroller.current.scrollTo({ x: 0, y: 0 });
setTimeout(() => {
timer = setTimeout(() => {
setScrollEvent(true);
}, 500);
}

return () => {
clearTimeout(timer);
};
}, [items]);

if (!items.length) return null;
Expand Down

0 comments on commit 1602f33

Please sign in to comment.