refactor: hook dependencies name everything the hooks read
The 12 react-hooks/exhaustive-deps warnings the gate let through: - ShareDialog and YearFilter built a fresh [] per render while their query loaded, so their memos recomputed on every render; they share one empty list now. - VideoEditor's drag effect called a seek/moveBoundary recreated each render; both are stable callbacks in its deps. - WizardProvider re-checks onboarding on exactly the fields it reads (not the me object, whose 60 s refetch would reopen a closed wizard). - Channels, Feed and PlexPlayer list the stable values they already used. - The player's keydown effect is bound once on purpose (its helpers read refs): said so, with a disable, as the codebase's other deliberate sites do. - dialogFocus and the YouTube player's cleanup read refs React may already have let go of; they use what they captured when the effect ran.
This commit is contained in:
@@ -230,15 +230,15 @@ export default function Feed({
|
||||
// rows are unchanged, so clearing overrides there would make a just-hidden card flash back.
|
||||
// Only a real refetch (page count doesn't grow) is authoritative.
|
||||
const pagesLenRef = useRef(0);
|
||||
const pagesLen = query.data?.pages?.length ?? 0;
|
||||
useEffect(() => {
|
||||
const len = query.data?.pages?.length ?? 0;
|
||||
const appended = len > pagesLenRef.current;
|
||||
pagesLenRef.current = len;
|
||||
const appended = pagesLen > pagesLenRef.current;
|
||||
pagesLenRef.current = pagesLen;
|
||||
if (!appended) {
|
||||
setOverrides({});
|
||||
setSavedOverrides({});
|
||||
}
|
||||
}, [query.dataUpdatedAt]);
|
||||
}, [query.dataUpdatedAt, pagesLen]);
|
||||
|
||||
// One shared query with the sidebar (same key + filters -> React Query dedupes to a single request):
|
||||
// the feed reads `.count`, the sidebar reads `.facets` (PERF-13, replaces feedCount + facets).
|
||||
|
||||
Reference in New Issue
Block a user