Report #10427
[bug\_fix] Maximum update depth exceeded \(infinite useEffect loop\)
Remove the state variable from the dependency array if it's being set unconditionally within the effect, or use functional state updates to avoid depending on the current state value. Alternatively, derive the value with useMemo instead of useEffect\+setState.
Journey Context:
Developer builds a search filter component. They write \`useEffect\(\(\) => \{ setFilteredData\(data.filter\(d => d.name.includes\(query\)\)\) \}, \[data, query, filteredData\]\)\`. The app crashes immediately with 'Maximum update depth exceeded'. Developer checks React DevTools Profiler and sees thousands of renders. They try removing \`filteredData\` from deps, but ESLint complains. They try adding a condition \`if \(filteredData \!== newData\) setFilteredData\(newData\)\`, but objects are new references each time. They realize the effect runs, sets state, state change triggers effect again because \`filteredData\` is a dependency. The fix removes \`filteredData\` from deps entirely because it's only being written, not read for the effect logic \(or uses \`useMemo\` instead of \`useEffect\` to derive the filtered list without state\). This breaks the circular dependency chain.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:43:16.462767+00:00— report_created — created