{
  "id": "react/state-update-in-effect-without-deps",
  "signature": "Error: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.",
  "signature_zh": "错误：超过最大更新深度。当组件在 useEffect 内部调用 setState，但 useEffect 没有依赖数组，或者某个依赖在每次渲染时都发生变化时，可能会发生这种情况。",
  "regex": "Error: Maximum update depth exceeded\\. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render\\.",
  "domain": "react",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A useEffect with a state update either lacks a dependency array (runs after every render) or has a dependency that mutates on every render (e.g., a new object/function), causing an infinite loop.",
  "root_cause_type": "generic",
  "root_cause_zh": "带有状态更新的 useEffect 要么缺少依赖数组（每次渲染后运行），要么有一个在每次渲染时都会发生变化的依赖（例如新的对象/函数），从而导致无限循环。",
  "versions": [
    {
      "version": "React 18.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "React 17.0.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If the effect needs to react to prop or state changes, an empty array makes it run only once, potentially missing updates and causing stale data.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Inline functions/objects are new references each render, so the effect runs every time, defeating the purpose.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Provide a proper dependency array with stable values. If the state update depends on previous state, use the functional update form: setState(prev => prev + 1).",
      "success_rate": 0.95,
      "how": "Provide a proper dependency array with stable values. If the state update depends on previous state, use the functional update form: setState(prev => prev + 1).",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the effect needs to react to a changing value, ensure that value is memoized with useMemo or useCallback to maintain referential stability.",
      "success_rate": 0.9,
      "how": "If the effect needs to react to a changing value, ensure that value is memoized with useMemo or useCallback to maintain referential stability.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Provide a proper dependency array with stable values. If the state update depends on previous state, use the functional update form: setState(prev => prev + 1).",
    "If the effect needs to react to a changing value, ensure that value is memoized with useMemo or useCallback to maintain referential stability."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://react.dev/reference/react/useEffect#updating-state-based-on-previous-state",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-08-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}