diff options
-rw-r--r-- | thallium-frontend/src/utils/hooks.ts | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/thallium-frontend/src/utils/hooks.ts b/thallium-frontend/src/utils/hooks.ts index 337ccf2..a98cfb3 100644 --- a/thallium-frontend/src/utils/hooks.ts +++ b/thallium-frontend/src/utils/hooks.ts @@ -8,8 +8,10 @@ export function useVisible(ref: RefObject<HTMLElement>) { const observer = new IntersectionObserver( ([entry]) => { setVisible(entry.isIntersecting); } ); + if (ref.current) observer.observe(ref.current); + return () => { observer.disconnect(); }; }, [ref]); |