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:
@@ -489,6 +489,10 @@ export default function PlayerModal({
|
||||
window.removeEventListener("keydown", onKey);
|
||||
// (The debounced volume write is flushed by useYtVolume's own unmount cleanup.)
|
||||
};
|
||||
// Bound once per player on purpose: every helper the handler calls reads its live state through
|
||||
// a ref (playerRef, navRef, maximizedRef, isFullscreenRef, the volume hook's own ref), so
|
||||
// re-binding on each render would only churn the listener, never change what a key does.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [onClose]);
|
||||
|
||||
// Create the player, resume from the saved position, checkpoint progress, and auto-mark watched at
|
||||
|
||||
Reference in New Issue
Block a user