Background
PushList.tsx uses a manual useEffect + fetch pattern for loading push records and status counts. This approach has several drawbacks:
- Triggers
react-hooks/set-state-in-effect lint warnings when async state-setting functions are called directly in effect bodies
- Requires
Promise.resolve().then() workarounds to satisfy the lint rule
- Does not deduplicate concurrent fetches or handle stale data correctly
- Background refresh intervals are manually managed with
setInterval/clearInterval
The load function currently passes the lint check only because the rule was added after that code was written.
Proposed fix
Replace the manual useEffect + fetchPushes / fetchPushCounts calls with React Query (useQuery). This provides:
- Automatic background refetch on a configurable interval
- Deduplication of concurrent requests
- Proper stale-while-revalidate semantics
- No lint workarounds needed
Scope
PushList.tsx — primary target (load and loadCounts effects)
- Other pages that use manual
useEffect + apiFetch may benefit from the same treatment
Notes
- This is a refactor, not a bug fix — the current workaround (
Promise.resolve().then()) is acceptable and consistent with the existing codebase
- Tracked here to ensure the lint pattern is addressed properly rather than accumulating more workarounds
Background
PushList.tsxuses a manualuseEffect+fetchpattern for loading push records and status counts. This approach has several drawbacks:react-hooks/set-state-in-effectlint warnings when async state-setting functions are called directly in effect bodiesPromise.resolve().then()workarounds to satisfy the lint rulesetInterval/clearIntervalThe
loadfunction currently passes the lint check only because the rule was added after that code was written.Proposed fix
Replace the manual
useEffect+fetchPushes/fetchPushCountscalls with React Query (useQuery). This provides:Scope
PushList.tsx— primary target (loadandloadCountseffects)useEffect+apiFetchmay benefit from the same treatmentNotes
Promise.resolve().then()) is acceptable and consistent with the existing codebase