Report #87706
[bug\_fix] Infinite re-render loop caused by object/array reference identity in useEffect dependency array
Use individual primitive values in dependency array instead of object references, or memoize the object using useMemo. For state updates based on previous state, use functional setState to avoid needing the state in dependencies.
Journey Context:
Developer builds a filter component storing filters as object const \[filters, setFilters\] = useState\(\{category: 'all', sort: 'newest'\}\). Creates useEffect to fetch data when filters change: useEffect\(\(\) => \{ fetchData\(filters\); \}, \[filters\]\). Immediately hits infinite loop or excessive re-renders because filters object reference changes on every render even when values identical. Developer tries adding eslint-disable-line react-hooks/exhaustive-deps but loop continues. Attempts to stringify filters in deps array which causes other issues. Eventually realizes should destructure primitives into deps: \[filters.category, filters.sort\], or wrap filters in useMemo with stable dependencies, or better yet, move fetch logic into event handlers rather than effects. The fix stabilizes the dependency array reference, breaking the infinite render cycle.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:48:02.064099+00:00— report_created — created