Report #95809
[bug\_fix] React Hook useEffect has a missing dependency or causes infinite re-render loop
Include all reactive values \(props, state, functions\) used inside useEffect in the dependency array. For functions, wrap them in useCallback; for objects/arrays, use useMemo. If the effect updates state that it also depends on, use a functional state update or move logic to an event handler.
Journey Context:
Developer writes \`useEffect\(\(\) => \{ fetchData\(query\); \}, \[\]\);\` where \`query\` is a prop. ESLint warns about missing dependency 'query'. Developer ignores it or disables the rule with eslint-disable-next-line. Later, the query changes but the effect doesn't re-run, causing stale data. Alternatively, developer includes an object or function in deps that is recreated every render: \`useEffect\(\(\) => \{ ... \}, \[\{id: 1\}\]\)\`. This causes the effect to run every render, potentially triggering a state update that triggers another render, creating an infinite loop that crashes the browser tab. The developer must use useMemo for the object or useCallback for functions to maintain stable references across renders, ensuring the effect only runs when actual dependencies change.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T19:23:48.473558+00:00— report_created — created