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:
parent
2a6ded288b
commit
3da5aba726
3 changed files with 13 additions and 2 deletions
|
@ -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);
|
||||
}, []);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue