From 5aa889fb08122670dff189758bfcf07c736c07dd Mon Sep 17 00:00:00 2001 From: ingawei Date: Fri, 30 Sep 2022 13:10:59 -0700 Subject: [PATCH] james changes --- web/components/scroll-to-top-button.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/web/components/scroll-to-top-button.tsx b/web/components/scroll-to-top-button.tsx index 0be44fe4..18eb525c 100644 --- a/web/components/scroll-to-top-button.tsx +++ b/web/components/scroll-to-top-button.tsx @@ -7,15 +7,14 @@ export function ScrollToTopButton(props: { className?: string }) { const { className } = props const [visible, setVisible] = useState(false) - const onScroll = () => { - if (window.scrollY > 500) { - setVisible(true) - } else { - setVisible(false) - } - } - useEffect(() => { + const onScroll = () => { + if (window.scrollY > 500) { + setVisible(true) + } else { + setVisible(false) + } + } window.addEventListener('scroll', onScroll, { passive: true }) return () => {