fix react-hooks/exhaustive-deps warnings

This commit is contained in:
2026-05-01 04:42:36 +03:00
parent a332293e83
commit 8886abf589
9 changed files with 26 additions and 36 deletions
+2 -4
View File
@@ -32,16 +32,14 @@ export default function PersonalSection({ itemId, showRewatchToggle }: Props) {
// notes correctly without leaking state).
useEffect(() => {
setLocalNote(entry?.note || '')
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [itemId])
}, [itemId, entry?.note])
// Debounce writes by 400ms.
useEffect(() => {
if (localNote === (entry?.note || '')) return
const id = setTimeout(() => setNote(itemId, localNote), 400)
return () => clearTimeout(id)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [localNote])
}, [localNote, entry?.note, itemId, setNote])
const rating = entry?.rating ?? 0
const rewatchCount = entry?.rewatchCount ?? 0
+5 -6
View File
@@ -95,21 +95,21 @@ function RouletteModal({
const pick = pool[pickIndex % Math.max(1, pool.length)] || null
function spin() {
const spin = useCallback(() => {
if (pool.length < 2) return
let next = pickIndex
// Avoid landing on the same pick consecutively.
while (next === pickIndex) next = Math.floor(Math.random() * pool.length)
setPickIndex(next)
setSpinNonce(n => n + 1)
}
}, [pool.length, pickIndex])
function open() {
const open = useCallback(() => {
if (!pick) return
const mediaType = pick.media_type === 'tv' || pick.first_air_date ? 'tv' : 'movie'
navigate(`/item/tmdb-${mediaType}-${pick.id}`)
onClose()
}
}, [pick, navigate, onClose])
useEffect(() => {
function onKey(e: KeyboardEvent) {
@@ -121,8 +121,7 @@ function RouletteModal({
}
window.addEventListener('keydown', onKey)
return () => window.removeEventListener('keydown', onKey)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [pickIndex, pool.length])
}, [pickIndex, pool.length, onClose, spin])
const title = pick?.title || pick?.name || ''
const year = (pick?.release_date || pick?.first_air_date || '').slice(0, 4)
+1 -2
View File
@@ -113,8 +113,7 @@ export default function RequestModal({ open, onClose, tmdbId, kind, tmdbData }:
const init: Record<number, boolean> = {}
for (const s of tvSeasons) init[s.season_number ?? 0] = true
setSeasonsRequested(init)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tmdbData?.id])
}, [kind, tvSeasons])
// Esc closes.
useEffect(() => {