Remove event after unmount

This commit is contained in:
DefectingCat
2022-11-28 18:01:24 +08:00
parent 9b472ef1ae
commit 1924723ce5

View File

@ -23,6 +23,7 @@ const MainLayout = ({ children }: Props) => {
}, []);
useEffect(() => {
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
}, [handleScroll]);
return (