From 368f42f04f7b690b06b5a6d13f468014ec9629ba Mon Sep 17 00:00:00 2001 From: iliya Date: Tue, 24 Mar 2026 18:06:08 +0200 Subject: [PATCH] fix(hooks): resolve react-hooks/refs lint errors breaking CI - useMarkCommentsRead: replace useRef().current with useCallback for stable ref callback (accessing ref during render is not allowed) - useAttachments: add eslint-disable for intentional ref sync pattern --- src/renderer/hooks/useAttachments.ts | 1 + src/renderer/hooks/useMarkCommentsRead.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/renderer/hooks/useAttachments.ts b/src/renderer/hooks/useAttachments.ts index 5816cce7..25a83497 100644 --- a/src/renderer/hooks/useAttachments.ts +++ b/src/renderer/hooks/useAttachments.ts @@ -61,6 +61,7 @@ export function useAttachments(options?: UseAttachmentsOptions): UseAttachmentsR // eslint-disable-next-line react-hooks/refs -- synchronous ref sync during render is intentional to avoid stale key in callbacks keyRef.current = persistenceKey; const onUnsupportedRef = useRef(options?.onUnsupportedFiles); + // eslint-disable-next-line react-hooks/refs -- synchronous ref sync during render is intentional to avoid stale callback in handlers onUnsupportedRef.current = options?.onUnsupportedFiles; // Sync ref with state diff --git a/src/renderer/hooks/useMarkCommentsRead.ts b/src/renderer/hooks/useMarkCommentsRead.ts index 12a6d797..07fcabe6 100644 --- a/src/renderer/hooks/useMarkCommentsRead.ts +++ b/src/renderer/hooks/useMarkCommentsRead.ts @@ -1,4 +1,4 @@ -import { useRef } from 'react'; +import { useCallback, useRef } from 'react'; /** * Provides a stable ref callback for the comments container. @@ -19,9 +19,9 @@ export function useMarkCommentsRead( const nodeRef = useRef(null); // Stable ref callback (no dependencies — just stores the node) - const refCallback = useRef((node: HTMLElement | null) => { + const refCallback = useCallback((node: HTMLElement | null) => { nodeRef.current = node; - }).current; + }, []); return refCallback; }