diff --git a/app/soapbox/hooks/useOnScreen.ts b/app/soapbox/hooks/useOnScreen.ts index 1ae207326..7cfd4f284 100644 --- a/app/soapbox/hooks/useOnScreen.ts +++ b/app/soapbox/hooks/useOnScreen.ts @@ -8,12 +8,14 @@ export const useOnScreen = (ref: React.MutableRefObject) => { ); React.useEffect(() => { - observer.observe(ref.current); + if (ref.current) { + observer.observe(ref.current); + } return () => { observer.disconnect(); }; - }, []); + }, [ref.current]); return isIntersecting; };