fix: add SSR safety and fix memory leak (qa-requested)

- Add 'use client' directive to GlobalBackground component
- Fix SSR-unsafe document access in usePageVisibility hook
- Fix memory leak in useIntersectionObserver cleanup function

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-25 06:41:49 +01:00
co-authored by Claude Sonnet 4.5
parent fb99c91561
commit 19d76d47ea
3 changed files with 11 additions and 5 deletions
+3 -1
View File
@@ -5,7 +5,9 @@ import { useState, useEffect } from 'react';
* @returns boolean - true when page is visible, false when hidden
*/
export const usePageVisibility = (): boolean => {
const [isVisible, setIsVisible] = useState<boolean>(!document.hidden);
const [isVisible, setIsVisible] = useState<boolean>(() =>
typeof document !== 'undefined' ? !document.hidden : true
);
useEffect(() => {
const handleVisibilityChange = () => {