aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--thallium-frontend/src/components/CartStatus.tsx2
-rw-r--r--thallium-frontend/src/utils/hooks.ts14
2 files changed, 8 insertions, 8 deletions
diff --git a/thallium-frontend/src/components/CartStatus.tsx b/thallium-frontend/src/components/CartStatus.tsx
index d65697a..cdb35f3 100644
--- a/thallium-frontend/src/components/CartStatus.tsx
+++ b/thallium-frontend/src/components/CartStatus.tsx
@@ -22,7 +22,7 @@ transition: all 0.25s;
${Card} {
box-shadow: none;
}
-`
+`;
const FloatingButton = styled(Button) <{ $visible: boolean }>`
position: fixed;
diff --git a/thallium-frontend/src/utils/hooks.ts b/thallium-frontend/src/utils/hooks.ts
index 79486a3..c68a4a6 100644
--- a/thallium-frontend/src/utils/hooks.ts
+++ b/thallium-frontend/src/utils/hooks.ts
@@ -1,17 +1,17 @@
import { useState, useEffect, useMemo } from "react";
import { type RefObject } from "react";
-export function useVisible(ref: RefObject<HTMLElement>, initialState: boolean = false) {
+export function useVisible(ref: RefObject<HTMLElement>, initialState = false) {
const [isVisible, setVisible] = useState(initialState);
const intersectionObserver = useMemo(() => {
return new IntersectionObserver(
- ([entry]) => { setVisible(entry.isIntersecting) },
+ ([entry]) => { setVisible(entry.isIntersecting); },
{
threshold: 0.5
}
- )
- }, [ref]);
+ );
+ }, []);
useEffect(() => {
@@ -19,7 +19,7 @@ export function useVisible(ref: RefObject<HTMLElement>, initialState: boolean =
intersectionObserver.observe(ref.current);
return () => { intersectionObserver.disconnect(); };
- }, [ref]);
+ }, [ref, intersectionObserver]);
return isVisible;
}
@@ -34,11 +34,11 @@ export function useMediaQuery(query: string) {
useEffect(() => {
const listenHook = (e: MediaQueryListEvent) => {
setMatches(e.matches);
- }
+ };
queryObject.addEventListener("change", listenHook);
- return () => queryObject.removeEventListener("change", listenHook);
+ return () => { queryObject.removeEventListener("change", listenHook); };
}, [queryObject]);
return matches;