diff --git a/src/components/shared/ScrollToTop.tsx b/src/components/shared/ScrollToTop.tsx index 4e8bcea..d573f86 100644 --- a/src/components/shared/ScrollToTop.tsx +++ b/src/components/shared/ScrollToTop.tsx @@ -21,12 +21,15 @@ const ScrollToTop = () => { } }; - window.addEventListener('scroll', listenToScroll); - return () => { - window.removeEventListener('scroll', listenToScroll); - }; + if (typeof globalThis !== 'undefined') { + globalThis.addEventListener('scroll', listenToScroll); + return () => { + globalThis.removeEventListener('scroll', listenToScroll); + }; + } }, []); + return ( <> {isVisible && (