mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-05-05 01:27:46 +07:00
removed redux completely
This commit is contained in:
parent
26e6d8d41b
commit
a4bb07e9cf
323 changed files with 2464 additions and 3348 deletions
16
src/hooks/dom/useScrollTop.ts
Normal file
16
src/hooks/dom/useScrollTop.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
|
||||
export const useScrollTop = () => {
|
||||
const [top, setTop] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const onScroll = () => {
|
||||
setTop(window.scrollY);
|
||||
};
|
||||
|
||||
window.addEventListener('scroll', onScroll);
|
||||
return () => window.removeEventListener('scroll', onScroll);
|
||||
}, []);
|
||||
|
||||
return top;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue