Report #15668
[bug\_fix] React Hook useEffect has a missing dependency: 'fetchData'. Either include it or remove the dependency array.
Include the missing dependency in the array. If the dependency is a function that causes infinite loops because it's recreated every render, stabilize it using useCallback with its own dependency array, or move the function definition inside the useEffect to remove it from the dependency array entirely.
Journey Context:
Developer writes useEffect\(\(\) => \{ fetchData\(\); \}, \[\]\) where fetchData is defined in the component. ESLint warns about missing fetchData dep. Developer adds \[fetchData\] but now the effect runs on every render because fetchData is re-declared every render \(const fetchData = async \(\) => \{...\}\), causing infinite loop or excessive API calls. Developer tries // eslint-disable-next-line react-hooks/exhaustive-deps which silences warning but creates stale closure bug where fetchData uses old state values. Finally, developer moves fetchData definition inside useEffect \(if not needed elsewhere\) or wraps fetchData in useCallback with stable dependencies, then includes stable fetchData in effect deps. This satisfies exhaustive-deps without infinite loops.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:44:53.754667+00:00— report_created — created