Report #7084
[bug\_fix] React Hook useEffect has missing dependencies: 'propX' and 'stateY'. Either include them or remove the dependency array
Include all reactive values \(props, state, and variables/functions derived from them\) used inside useEffect in the dependency array. If including a function causes infinite loops, wrap the function definition in useCallback. If including an object/array causes loops, use useMemo or track primitive values \(IDs\) instead.
Journey Context:
Developer creates a search component that fetches results when query or filters change. They write: useEffect\(\(\) => \{ fetchResults\(query, filters\); \}, \[query\]\). ESLint warns about missing 'filters' dependency. Developer ignores it to avoid infinite loops. Later, when filters change, the results don't update, causing stale UI. Developer adds 'filters' to deps: \[query, filters\]. Now every keystroke in the query input triggers a re-fetch because 'filters' is an object \{\} recreated on every render, causing referential inequality. Developer tries JSON.stringify\(filters\) in deps, causing eslint warning about unstable dependency. Realizes the issue: objects are recreated every render. Solution: either memoize the filters object with useMemo in parent, or track only the primitive filter values \(categoryId, sortOrder\) in the dependency array instead of the whole filters object. Also implements useCallback for the fetch function if it's defined in component.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:45:40.047786+00:00— report_created — created