aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-09-11 17:16:09 +0100
committerGravatar Joe Banks <[email protected]>2024-09-11 17:16:09 +0100
commitf0d2516826292c38e1d6a2ecf29a085a09f2b9ea (patch)
treec4c2949c93c976d9ed4a8294020d1f5725042bb9
parentSet packageManager field in package.json (diff)
Type corrections
I have a language server now.
-rw-r--r--thallium-frontend/src/utils/hooks.ts6
1 files 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<HTMLElement>) {
const [isVisible, setVisible] = useState(false)
@@ -7,7 +8,8 @@ export function useVisible(ref: RefObject<HTMLElement>) {
const observer = new IntersectionObserver(
([entry]) => setVisible(entry.isIntersecting)
)
- observer.observe(ref.current)
+ if (ref.current)
+ observer.observe(ref.current)
return () => observer.disconnect()
}, [])