From f0d2516826292c38e1d6a2ecf29a085a09f2b9ea Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Wed, 11 Sep 2024 17:16:09 +0100 Subject: Type corrections I have a language server now. --- thallium-frontend/src/utils/hooks.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/thallium-frontend/src/utils/hooks.ts b/thallium-frontend/src/utils/hooks.ts index 9b478f7..997f274 100644 --- a/thallium-frontend/src/utils/hooks.ts +++ b/thallium-frontend/src/utils/hooks.ts @@ -1,4 +1,5 @@ -import { useMemo, useState, useEffect } from "react"; +import { useState, useEffect } from "react"; +import { type RefObject } from "react"; export function useVisible(ref: RefObject) { const [isVisible, setVisible] = useState(false) @@ -7,7 +8,8 @@ export function useVisible(ref: RefObject) { const observer = new IntersectionObserver( ([entry]) => setVisible(entry.isIntersecting) ) - observer.observe(ref.current) + if (ref.current) + observer.observe(ref.current) return () => observer.disconnect() }, []) -- cgit v1.2.3