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
This commit is contained in:
parent
94fc564bf5
commit
368f42f04f
2 changed files with 4 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<HTMLElement | null>(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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue