1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

(nextjs) fixed header appearance for SSR

This commit is contained in:
Fedor Katurov 2022-01-19 14:44:18 +07:00
parent 2a6ded288b
commit 3da5aba726
3 changed files with 13 additions and 2 deletions

View file

@ -4,11 +4,14 @@ export const useScrollTop = () => {
const [top, setTop] = useState(typeof window !== 'undefined' ? window.scrollY : 0);
useEffect(() => {
setTop(window.scrollY);
const onScroll = () => {
setTop(window.scrollY);
};
window.addEventListener('scroll', onScroll);
return () => window.removeEventListener('scroll', onScroll);
}, []);